nanomunchers.graph
Class GridGraph
java.lang.Object
nanomunchers.graph.GridGraph
- All Implemented Interfaces:
- Graph
- public class GridGraph
- extends java.lang.Object
- implements Graph
A Graph that looks like:
o-o-o-o
| | | |
o-o-o-o
| | | |
o-o-o-o
Formally, No node has a degree higher than 4.
All nodes have at least 2 neighbors.
And the graph is Planar.
- Author:
- David Kaplin
Constructor Summary |
protected |
GridGraph(int width,
int height)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
nodes
protected Node[] nodes
edges
protected Edge[] edges
graphwidth
protected int graphwidth
graphheight
protected int graphheight
GridGraph
protected GridGraph(int width,
int height)
- Parameters:
width
- height
-
getNodes
public Node[] getNodes()
- Specified by:
getNodes
in interface Graph
- Returns:
- the nodes that make up a graph.
- See Also:
Graph.getNodes()
getUniqueEdges
public Edge[] getUniqueEdges()
- Specified by:
getUniqueEdges
in interface Graph
- Returns:
- if the graph contians bi-directional edges return only
(A,B) as opposed to (A,B) and (B,A)
- See Also:
Graph.getUniqueEdges()
getConnectedComponents
public Graph[] getConnectedComponents()
- Really simple. The entire graph is fully connected.
- Specified by:
getConnectedComponents
in interface Graph
- Returns:
- Subgraphs that are strongly connected.
- See Also:
Graph.getConnectedComponents()
clear
public void clear()
- Description copied from interface:
Graph
- Clears any marked nodes on the graph.
- Specified by:
clear
in interface Graph
- See Also:
Graph.clear()
getNeighbors
public Edge[] getNeighbors(Node n)
- Specified by:
getNeighbors
in interface Graph
- Parameters:
n
- node to start at- See Also:
Graph.getNeighbors(nanomunchers.graph.Node)
getWidth
public int getWidth()
- Specified by:
getWidth
in interface Graph
- Returns:
- largest span of nodes in width
- See Also:
Graph.getWidth()
getHeight
public int getHeight()
- Specified by:
getHeight
in interface Graph
- Returns:
- largest span of nodes in height
- See Also:
Graph.getHeight()