mocman.util.data
Class Graph<TN,TE>
java.lang.Object
mocman.util.data.Graph<TN,TE>
public class Graph<TN,TE>
- extends java.lang.Object
Generic Graph type
It contains generic Nodes (Node),
generic Edges (Node)
and the graph representation.
It is designed to be shown on an awt from.
This class is used later by the GraphPrinter class.
- Author:
- Tibor Zoltan Varkonyi
Constructor Summary |
Graph()
Default constructor |
Method Summary |
void |
add(Node<TN> n)
Adds a node |
void |
addEdge(int n1,
int n2,
Node<TE> n)
Adds a new edge between the given nodes |
int |
edgeCount()
Gets the edge count |
Node<TE> |
edges(int i)
Gets an edge |
Node<TE> |
getEdge(int n1,
int n2)
Gets the edge between the node indexes. |
Node<TE> |
getTwoWayEdge(int n1,
int n2)
Gets the edge between the node indexes. |
boolean |
isEdge(int n1,
int n2)
Checks if there is an edge between the node indexes. |
boolean |
isTwoWayEdge(int n1,
int n2)
Checks if there is an edge between the node indexes. |
int |
nodeCount()
Gets the node count |
Node<TN> |
nodes(int i)
Gets a node |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Graph
public Graph()
- Default constructor
nodeCount
public int nodeCount()
- Gets the node count
edgeCount
public int edgeCount()
- Gets the edge count
nodes
public Node<TN> nodes(int i)
- Gets a node
edges
public Node<TE> edges(int i)
- Gets an edge
add
public void add(Node<TN> n)
- Adds a node
isEdge
public boolean isEdge(int n1,
int n2)
- Checks if there is an edge between the node indexes.
Use this for directed graphs
isTwoWayEdge
public boolean isTwoWayEdge(int n1,
int n2)
- Checks if there is an edge between the node indexes.
Use this for undirected graphs
getEdge
public Node<TE> getEdge(int n1,
int n2)
- Gets the edge between the node indexes.
Use this for directed graphs
getTwoWayEdge
public Node<TE> getTwoWayEdge(int n1,
int n2)
- Gets the edge between the node indexes.
Use this for undirected graphs
addEdge
public void addEdge(int n1,
int n2,
Node<TE> n)
- Adds a new edge between the given nodes