Class GraphFunctions

java.lang.Object
mgui.interfaces.Utility
mgui.interfaces.graphs.util.GraphFunctions

public class GraphFunctions
extends Utility
Provides utility functions for Graphs.
Since:
1.0
Version:
1.0
Author:
Andrew Reid
  • Constructor Details

    • GraphFunctions

      public GraphFunctions()
  • Method Details

    • getNodeFactory

      public static org.apache.commons.collections15.Factory<AbstractGraphNode> getNodeFactory()
    • getNodeFactory

      public static <T extends AbstractGraphNode> org.apache.commons.collections15.Factory<AbstractGraphNode> getNodeFactory​(java.lang.Class<T> node_class, java.lang.String prefix, boolean add_ids, boolean has_locations)
    • getEdgeFactory

      public static org.apache.commons.collections15.Factory<AbstractGraphEdge> getEdgeFactory()
    • getEdgeFactory

      public static <T extends AbstractGraphEdge> org.apache.commons.collections15.Factory<AbstractGraphEdge> getEdgeFactory​(java.lang.Class<T> edge_class)
    • getLayoutTypes

      public static java.util.HashMap<java.lang.String,​java.lang.Class<?>> getLayoutTypes()
      Returns list of available graph layouts.

      TODO: load these into a GraphEnvironment.

      Returns:
      a HashMap of available layout types, and their corresponding classes
    • getLayoutTypes2

      public static java.util.HashMap<java.lang.String,​java.lang.Class> getLayoutTypes2()
      Returns list of available graph layouts. Unparameterized, because generics can be a pain in the ass sometimes...

      TODO: load these into a GraphEnvironment.

      Returns:
      a HashMap of available layout types, and their corresponding classes
    • getLayout3DTypes2

      public static java.util.HashMap<java.lang.String,​java.lang.Class> getLayout3DTypes2()
      Returns list of available 3D graph layouts. Revised because generics can be a bitch.

      TODO: load these into a GraphEnvironment.

      Returns:
      a HashMap of available layout types, and their corresponding classes
    • getLayout3DTypes

      public static java.util.HashMap<java.lang.String,​java.lang.Class<?>> getLayout3DTypes()
      Returns list of available 3D graph layouts.

      TODO: load these into a GraphEnvironment.

      Returns:
      a HashMap of available layout types, and their corresponding classes
    • getVertexLabeller

      public static org.apache.commons.collections15.Transformer<AbstractGraphNode,​java.lang.String> getVertexLabeller()
      Returns a Transformer object which produces a label for a vertex.
      Returns:
    • getEdgeLabeller

      public static org.apache.commons.collections15.Transformer<AbstractGraphEdge,​java.lang.String> getEdgeLabeller()
      Returns a Transformer object which produces a label for an edge.
      Returns:
    • createNodeShape

      public static NodeShape createNodeShape​(java.lang.String line)
      Creates a Shape instance, used to render graph nodes, by parsing a line of text, with the format:

      [name] [is-fillable] [qualified-class-name] [space delimited parameter list]

      Or, to load an path:

      [name] [is-fillable] java.awt.Path2D$[Float|Double] [SVG-like M (move) and L (line) commands; e.g., M 1,5 L 10,5 M 5,1 L 5,10 ]

      Parameters:
      line -
      Returns:
      the shape, or null if none was created
    • loadNodeShapeFromSvg

      protected static NodeShape loadNodeShapeFromSvg​(java.lang.String filename)
      Loads a node shape from an svg file
      Parameters:
      filename -
    • scaleToGraphExtents

      public static boolean scaleToGraphExtents​(InterfaceGraphDisplay display)
      Determines the current extents of this display's graph and scales/translates to it
      Parameters:
      display -
      Returns:
    • getLabelPositions

      public static java.util.ArrayList<java.lang.String> getLabelPositions()
      Get a list of possible node label positions, as Strings.
      Returns:
    • getLabelPosition

      public static edu.uci.ics.jung.visualization.renderers.Renderer.VertexLabel.Position getLabelPosition​(java.lang.String pos)
      Returns the label position associated with the String pos.
      Returns:
    • getEdgeVisibilityPredicate

      public static GraphFunctions.EdgeVisibility getEdgeVisibilityPredicate​(boolean initial)
      Returns a predicate object to control the visibility of edges in a graph.
      Parameters:
      initial -
      Returns:
    • getNodeVisibilityPredicate

      public static GraphFunctions.NodeVisibility getNodeVisibilityPredicate​(boolean initial)
      Returns a predicate object to control the visibility of nodes in a graph.
      Parameters:
      initial -
      Returns:
    • getArrowVisibilityPredicate

      public static GraphFunctions.ArrowVisibility getArrowVisibilityPredicate​(boolean initial)
      Returns a predicate object to control the visibility of edge arrows in a graph.
      Parameters:
      initial -
      Returns:
    • getNodeLabelRenderer

      public static GraphFunctions.GraphNodeLabelRenderer getNodeLabelRenderer​(edu.uci.ics.jung.visualization.renderers.Renderer.VertexLabel.Position position)
      Returns a node label renderer which can be turned off.
      Parameters:
      position -
      Returns:
    • getEdgeLabelRenderer

      public static GraphFunctions.GraphEdgeLabelRenderer getEdgeLabelRenderer()
      Returns an edge label renderer which can be turned off.
      Parameters:
      position -
      Returns:
    • getShortestPaths

      public static Jama.Matrix getShortestPaths​(InterfaceAbstractGraph graph)
      Returns an N x N matrix with the shortest paths lengths between each pair of vertices i and j, in graph.
      Parameters:
      graph -
      Returns:
    • getShortestPaths

      public static Jama.Matrix getShortestPaths​(InterfaceAbstractGraph graph, java.util.ArrayList<java.lang.Integer> vertices)
      Returns an N x N matrix with the shortest paths lengths between each pair of vertices i and j, in vertices.
      Parameters:
      graph -
      vertices - The list of vertices for which to obtain distances
      Returns:
    • getDistanceWeightedGraphForMesh

      public static InterfaceAbstractGraph getDistanceWeightedGraphForMesh​(Mesh3D mesh)
      Converts mesh to a weighted graph.
      Parameters:
      mesh -
      Returns: