|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.cau.cs.kieler.synccharts.codegen.sc.Graph
public class Graph
An implementation of an unweighted, directed graph using an adjacency matrix or an adjacency list for encoding the set of edges.
Field Summary | |
---|---|
static int |
NO_EDGE
There is no edge between two nodes. |
static int |
STRONG_EDGE
A Strong edge between two nodes (default edge). |
static int |
WEAK_EDGE
A weak edge between two nodes. |
Constructor Summary | |
---|---|
Graph(int n,
boolean isList)
Constructs a new unweighted, directed graph with n vertices and no edges. |
Method Summary | |
---|---|
void |
addEdge(int i,
int j,
int edgeType)
Adds an edge between the vertices with the indices i and j to this
graph. |
int |
degree(int i)
Returns the degree of a vertex i , i.e., the number of vertices. |
Enumerator |
enumerateAdjacentVertices(int i)
Returns an enumeration of adjacent vertices of the graph. |
boolean |
hasEdge(int i,
int j)
Returns true, if there is an edge between the vertices with the indices i and
j within this graph, and false otherwise. |
int |
numberOfEdges()
Returns the number of edges of this graph. |
int |
numberOfVertices()
Returns the number of vertices of this graph. |
void |
print()
Prints the Graph in a simple way to the console. |
LinkedList<Integer> |
topologicalSort()
returns a linked list with the topological sort of the graph (just implemented for adjacency lists). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NO_EDGE
public static final int STRONG_EDGE
public static final int WEAK_EDGE
Constructor Detail |
---|
public Graph(int n, boolean isList)
n
vertices and no edges. Use
addEdge(int, int, int)
in order to add edges.
n
- the number of vertices of the new graphisList
- specifies if the graph is represented in a list or a matrix. If isList is true the
representation is a list.#addEdge(int, int)
Method Detail |
---|
public Enumerator enumerateAdjacentVertices(int i)
i
- the number of the vertex
public void addEdge(int i, int j, int edgeType)
i
and j
to this
graph.
i
- the index of the vertex the new edge starts atj
- the index of the vertex the new edge points toedgeType
- the type of an edge (STRONG_EDGE, WEAK_EDGE or NO_EDGE)public int numberOfEdges()
public int numberOfVertices()
public boolean hasEdge(int i, int j)
i
and
j
within this graph, and false otherwise.
i
- the index of the start vertex to checkj
- the index of the end vertex to check
i
and
j
within this graph, andpublic int degree(int i)
i
, i.e., the number of vertices. which are
adjacent to i
,
i
- the index of the vertex
i
public void print()
public LinkedList<Integer> topologicalSort()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |