com.mxgraph.analysis

## Class mxGraphGenerator

- java.lang.Object
- - com.mxgraph.analysis.mxGraphGenerator

-     public class mxGraphGenerator
      extends java.lang.Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `mxGraphGenerator(mxGeneratorFunction generatorFunction, mxCostFunction costFunction)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `getBipartiteGraph(mxAnalysisGraph aGraph, int numVerticesGroup1, int numVerticesGroup2)`
    `void` | `getCompleteBipartiteGraph(mxAnalysisGraph aGraph, int numVerticesGroup1, int numVerticesGroup2)`
    `void` | `getCompleteGraph(mxAnalysisGraph aGraph, int numVertices)`
    `mxCostFunction` | `getCostFunction()`
    `void` | `getFriendshipWindmillGraph(mxAnalysisGraph aGraph, int numBranches, int branchSize)`
    `mxGeneratorFunction` | `getGeneratorFunction()`
    `static mxGeneratorFunction` | `getGeneratorFunction(mxGraph graph, boolean weighted, double minWeight, double maxWeight)`
    `void` | `getGridGraph(mxAnalysisGraph aGraph, int numColumns, int numRows)`
    `void` | `getKingGraph(mxAnalysisGraph aGraph, int xDim, int yDim)`
    `java.lang.Object[]` | `getKingMoveVertexes(mxAnalysisGraph aGraph, int xDim, int yDim, int xCoord, int yCoord)`
    `void` | `getKnightGraph(mxAnalysisGraph aGraph, int xDim, int yDim)`
    `java.lang.Object[]` | `getKnightMoveVertexes(mxAnalysisGraph aGraph, int xDim, int yDim, int xCoord, int yCoord)`
    `void` | `getKnightTour(mxAnalysisGraph aGraph, int xDim, int yDim, int startVertexValue)`
    `java.lang.Double` | `getNewEdgeValue(mxAnalysisGraph aGraph)` Creates a new edge value based on graph properties in mxAnalysisGraph.
    `void` | `getNullGraph(mxAnalysisGraph aGraph, int numVertices)`
    `void` | `getPathGraph(mxAnalysisGraph aGraph, int numVertices)`
    `void` | `getPetersenGraph(mxAnalysisGraph aGraph)`
    `int` | `getRandomInt(int minValue, int maxValue)`
    `void` | `getSimpleRandomGraph(mxAnalysisGraph aGraph, int numNodes, int numEdges, boolean allowSelfLoops, boolean allowMultipleEdges, boolean forceConnected)` Generates a random graph
    `void` | `getSimpleRandomTree(mxAnalysisGraph aGraph, int vertexCount)` Generates a random tree graph
    `void` | `getStarGraph(mxAnalysisGraph aGraph, int numVertices)`
    `int[]` | `getVertexGridCoords(int xDim, int yDim, int value)` use this only with the grid graph, and various chess-board graphs, because of vertex ordering
    `void` | `getWheelGraph(mxAnalysisGraph aGraph, int numVertices)`
    `void` | `getWindmillGraph(mxAnalysisGraph aGraph, int numBranches, int branchSize)`
    `void` | `oneSpanningTree(mxAnalysisGraph aGraph, boolean forceConnected, boolean forceSimple)`
    `void` | `setBipartiteGraphSpacing(mxAnalysisGraph aGraph, int numVerticesGroup1, int numVerticesGroup2, double vertexSpacing, double groupSpacing)` Sets the physical spacing between vertices in a bipartite graph.
    `void` | `setCostFunction(mxCostFunction costFunction)`
    `void` | `setGridGraphSpacing(mxAnalysisGraph aGraph, double xSpacing, double ySpacing, int numColumns, int numRows)` Sets the physical spacing between vertices in a grid graph.
    `void` | `setPathGraphSpacing(mxAnalysisGraph aGraph, double spacing)` Sets the physical spacing between vertices in a path graph.
    `void` | `setStarGraphLayout(mxAnalysisGraph aGraph, double graphSize)` Sets the physical size of a star graph.
    `void` | `setWindmillGraphLayout(mxAnalysisGraph aGraph, int numBranches, int numVerticesInBranch, double graphSize)` Sets the layout of a windmill graph.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### mxGraphGenerator

          public mxGraphGenerator(mxGeneratorFunction generatorFunction,
                          mxCostFunction costFunction)

  - ### Method Detail

    - #### getNullGraph

          public void getNullGraph(mxAnalysisGraph aGraph,
                          int numVertices)

      Parameters:
        `aGraph` -
        `numVertexes` -

    - #### getCompleteGraph

          public void getCompleteGraph(mxAnalysisGraph aGraph,
                              int numVertices)

      Parameters:
        `aGraph` -
        `numVertices` - number of vertices

    - #### getGridGraph

          public void getGridGraph(mxAnalysisGraph aGraph,
                          int numColumns,
                          int numRows)

      Parameters:
        `aGraph` -
        `numRows` - - number of rows in the grid graph
        `numColumns` - - number of columns in the grid graph

    - #### setGridGraphSpacing

          public void setGridGraphSpacing(mxAnalysisGraph aGraph,
                                 double xSpacing,
                                 double ySpacing,
                                 int numColumns,
                                 int numRows)

      Sets the physical spacing between vertices in a grid graph. This works for now only for a graph generated with mxGraphCreator.getGridGraph() only after creating the graph
      Parameters:
        `aGraph` -
        `xSpacing` - - horizontal spacing between vertices
        `ySpacing` - - vertical spacing between vertices
        `numRows` - - number of rows in the grid graph
        `numColumns` - - number of columns in the grid graph

    - #### getBipartiteGraph

          public void getBipartiteGraph(mxAnalysisGraph aGraph,
                               int numVerticesGroup1,
                               int numVerticesGroup2)

      Parameters:
        `aGraph` -
        `numVerticesGroup1` - number of vertices in group 1
        `numVerticesGroup2` - number of vertices in group 2

    - #### setBipartiteGraphSpacing

          public void setBipartiteGraphSpacing(mxAnalysisGraph aGraph,
                                      int numVerticesGroup1,
                                      int numVerticesGroup2,
                                      double vertexSpacing,
                                      double groupSpacing)

      Sets the physical spacing between vertices in a bipartite graph. This works for now only for a graph generated with mxGraphCreator.getBipartiteGraph() only after creating the graph
      Parameters:
        `aGraph` -
        `numVerticesGroup1` - - number of vertices in group 1
        `numVerticesGroup2` - - number of vertices in group 2
        `vertexSpacing` - - vertical spacing between vertices in the same group
        `groupSpacing` - - spacing between groups

    - #### getCompleteBipartiteGraph

          public void getCompleteBipartiteGraph(mxAnalysisGraph aGraph,
                                       int numVerticesGroup1,
                                       int numVerticesGroup2)

      Parameters:
        `aGraph` -
        `numVerticesGroup1` - number of vertices in group 1
        `numVerticesGroup2` - number of vertices in group 2

    - #### getKnightGraph

          public void getKnightGraph(mxAnalysisGraph aGraph,
                            int xDim,
                            int yDim)

      Parameters:
        `aGraph` -
        `xDim` -
        `yDim` -

    - #### getKnightMoveVertexes

          public java.lang.Object[] getKnightMoveVertexes(mxAnalysisGraph aGraph,
                                                 int xDim,
                                                 int yDim,
                                                 int xCoord,
                                                 int yCoord)

      Parameters:
        `aGraph` -
        `xDim` - x dimension of chess-board, size starts from 1
        `yDim` - y dimension of chess-board, size starts from 1
        `xCoord` - x coordinate on the chess-board, coordinate starts from 1
        `yCoord` - y coordinate on the chess-board, coordinate starts from 1
      Returns:
        a list of ALL vertexes which would be valid moves from the current position, regardless if they were visited or not Note that both dimensions and both coordinates must be positive

    - #### getVertexGridCoords

          public int[] getVertexGridCoords(int xDim,
                                  int yDim,
                                  int value)

      use this only with the grid graph, and various chess-board graphs, because of vertex ordering
      Parameters:
        `xDim` - x dimension of chess-board, size starts from 1
        `yDim` - y dimension of chess-board, size starts from 1
        `value` - value of the vertex that needs coordinates returned
      Returns:
        int[x,y] where x and y are the coordinates in the grid or chess-board Note that both dimensions must be positive

    - #### getKingGraph

          public void getKingGraph(mxAnalysisGraph aGraph,
                          int xDim,
                          int yDim)

      Parameters:
        `xDim` -
        `yDim` -
        `weights` - Return a king graph of size xDim x yDim Note that the minimum size is 4x4

    - #### getKingMoveVertexes

          public java.lang.Object[] getKingMoveVertexes(mxAnalysisGraph aGraph,
                                               int xDim,
                                               int yDim,
                                               int xCoord,
                                               int yCoord)

      Parameters:
        `aGraph` -
        `xDim` - x dimension of the chessboard
        `yDim` - y dimension of the chessboard
        `xCoord` - the current x position of the king
        `yCoord` - the current y position of the king
      Returns:
        list of all possible moves of a king from the specified position Note that both dimensions and both coordinates must be positive

    - #### getPetersenGraph

          public void getPetersenGraph(mxAnalysisGraph aGraph)

      Parameters:
        `aGraph` - Returns a Petersen graph

    - #### getPathGraph

          public void getPathGraph(mxAnalysisGraph aGraph,
                          int numVertices)

      Parameters:
        `aGraph` -
        `numVertices` - Returns a path graph

    - #### setPathGraphSpacing

          public void setPathGraphSpacing(mxAnalysisGraph aGraph,
                                 double spacing)

      Sets the physical spacing between vertices in a path graph. This works for now only for a graph generated with mxGraphCreator.getPathGraph() only after creating the graph
      Parameters:
        `aGraph` -
        `spacing` -

    - #### getStarGraph

          public void getStarGraph(mxAnalysisGraph aGraph,
                          int numVertices)

      Parameters:
        `aGraph` -
        `numVertices` - Returns a star graph Note that minimum vertex number is 4

    - #### setStarGraphLayout

          public void setStarGraphLayout(mxAnalysisGraph aGraph,
                                double graphSize)

      Sets the physical size of a star graph. This works for now only for a graph generated with mxGraphCreator.getStarGraph() and getWheelGraph()
      Parameters:
        `aGraph` -
        `graphSize` -

    - #### getWheelGraph

          public void getWheelGraph(mxAnalysisGraph aGraph,
                           int numVertices)

      Parameters:
        `aGraph` -
        `numVertices` - Returns a wheel graph. Note that numVertices has to be at least 4.

    - #### getFriendshipWindmillGraph

          public void getFriendshipWindmillGraph(mxAnalysisGraph aGraph,
                                        int numBranches,
                                        int branchSize)

      Parameters:
        `aGraph` -
        `numBranches` - number of branches (minimum >= 2)
        `branchSize` - number of vertices in a single branch (minimum >= 2) Returns a friendship windmill graph (aka Dutch windmill)

    - #### getWindmillGraph

          public void getWindmillGraph(mxAnalysisGraph aGraph,
                              int numBranches,
                              int branchSize)

      Parameters:
        `aGraph` -
        `numBranches` - - number of branches (minimum >= 2)
        `branchSize` - - number of vertices in a single branch (minimum >= 2) Returns a windmill graph

    - #### setWindmillGraphLayout

          public void setWindmillGraphLayout(mxAnalysisGraph aGraph,
                                    int numBranches,
                                    int numVerticesInBranch,
                                    double graphSize)

      Sets the layout of a windmill graph. Use this method only for graphs generated with mxGraphGenerator.getWindmillGraph() and getFriendshitWindmillGraph()
      Parameters:
        `aGraph` -
        `numBranches` -
        `numVerticesInBranch` -
        `graphSize` -

    - #### getSimpleRandomGraph

          public void getSimpleRandomGraph(mxAnalysisGraph aGraph,
                                  int numNodes,
                                  int numEdges,
                                  boolean allowSelfLoops,
                                  boolean allowMultipleEdges,
                                  boolean forceConnected)

      Generates a random graph
      Parameters:
        `aGraph` -
        `numNodes` - number of vertexes
        `numEdges` - number of edges (may be inaccurate if forceConnected is set to true
        `allowSelfLoops` - if true, there will be a chance that self loops will be generated too
        `allowMultipleEdges` - if true, there will be a chance that multiple edges will be generated (multiple edges between the same two vertices)
        `forceConnected` - if true the resulting graph will be always connected, but this may alter numEdges

    - #### getSimpleRandomTree

          public void getSimpleRandomTree(mxAnalysisGraph aGraph,
                                 int vertexCount)

      Generates a random tree graph
      Parameters:
        `aGraph` -
        `vertexCount` -

    - #### getNewEdgeValue

          public java.lang.Double getNewEdgeValue(mxAnalysisGraph aGraph)

      Creates a new edge value based on graph properties in mxAnalysisGraph. Used mostly when creating new edges during graph generation.
      Parameters:
        `aGraph` -
      Returns:

    - #### getGeneratorFunction

          public static mxGeneratorFunction getGeneratorFunction(mxGraph graph,
                                                 boolean weighted,
                                                 double minWeight,
                                                 double maxWeight)

      Parameters:
        `graph` -
        `weighted` - if true, the edges will be weighted, otherwise all will have default value (1.0)
        `minWeight` - minimum edge weight if weighted
        `maxWeight` - maximum edge weight if weighted
      Returns:
        a generator function

    - #### getGeneratorFunction

          public mxGeneratorFunction getGeneratorFunction()

    - #### getRandomInt

          public int getRandomInt(int minValue,
                         int maxValue)

      Parameters:
        `minValue` -
        `maxValue` -
      Returns:
        a random integer in the interval [minValue, maxValue]

    - #### oneSpanningTree

          public void oneSpanningTree(mxAnalysisGraph aGraph,
                             boolean forceConnected,
                             boolean forceSimple)
                               throws StructuralException

      Parameters:
        `graph` -
        `forceConnected` - if true, an unconnected graph is made connected
        `forceSimple` - if true, a non-simple graph is made simple Calculates one spanning tree of graph, which doesn't have to be but can be minimal (this is faster than minimal spanning tree, so if you need any spanning tree, use this one) Self loops and multiple edges are automatically removed! Also, unconnected graphs are made connected!
      Throws:
        `StructuralException` - the graph has to be simple (no self-loops and no multiple edges)

    - #### getKnightTour

          public void getKnightTour(mxAnalysisGraph aGraph,
                           int xDim,
                           int yDim,
                           int startVertexValue)
                             throws StructuralException

      Parameters:
        `aGraph` -
        `xDim` - x dimension of the chessboard
        `yDim` - y dimension of the chessboard
        `startVertexValue` - vertex where the tour will start
      Throws:
        `StructuralException` - not all size combinations are allowed, see wikipedia for a more detailed explanation Returns a Knight's Tour graph

    - #### getCostFunction

          public mxCostFunction getCostFunction()

    - #### setCostFunction

          public void setCostFunction(mxCostFunction costFunction)

Copyright (c) 2010 Gaudenz Alder. All rights reserved.