jBNC Toolbox

jbnc.graphs
Class Graph

java.lang.Object
  extended byjbnc.graphs.Graph

public class Graph
extends java.lang.Object

Description of the Class

Since:
June 1, 1999
Author:
Jarek Sacha

Field Summary
protected  java.util.HashMap vertices
           
 
Constructor Summary
Graph()
           
 
Method Summary
 void addEdge(Edge e)
           
 void addEdge(Vertex x, Vertex y)
           
 void addVertex(Vertex x)
           
 void clear()
          Remove all vertices and edges.
 boolean contains(Vertex x)
          Returns true if vertex x is present in the graph.
 void dump()
          Description of the Method
 int[] getChildrenOf(int parentIndex)
          Return all children nodes of the parent node with given index.
 Vertex[] getChildrenOf(Vertex parent)
          Return all children nodes of the given parent node.
 Edge[] getEdges()
           
 int getNumberOfVertices()
          Returns number of vertices in the graph.
 Vertex getVertex(int index)
          Return vertex with given index.
 Vertex[] getVertices()
          Return vertices as an array.
static void main(java.lang.String[] arg)
          Test class Graph.
 Edge removeEdge(Vertex in, Vertex out)
          Remove directed edge from the graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vertices

protected java.util.HashMap vertices
Constructor Detail

Graph

public Graph()
Method Detail

main

public static void main(java.lang.String[] arg)
Test class Graph.

Parameters:
arg - The command line arguments

getEdges

public Edge[] getEdges()
Returns:
The Edges value

getNumberOfVertices

public int getNumberOfVertices()
Returns number of vertices in the graph.

Returns:
The NumberOfVertices value

getVertex

public Vertex getVertex(int index)
Return vertex with given index.

Parameters:
index - Description of Parameter
Returns:
The Vertex value

getVertices

public Vertex[] getVertices()
Return vertices as an array.

Returns:
The Vertices value

getChildrenOf

public Vertex[] getChildrenOf(Vertex parent)
Return all children nodes of the given parent node.

Parameters:
parent - Parent.
Returns:
Array of children if parent is present in the graph, otherwise null.

getChildrenOf

public int[] getChildrenOf(int parentIndex)
Return all children nodes of the parent node with given index.

Parameters:
parentIndex - Description of Parameter
Returns:
Array of children if parent is present in the graph, otherwise null.

clear

public void clear()
Remove all vertices and edges.


addVertex

public void addVertex(Vertex x)
               throws java.lang.Exception
Parameters:
x - The feature to be added to the Vertex attribute
Throws:
java.lang.Exception - Vertex is null.

addEdge

public void addEdge(Vertex x,
                    Vertex y)
             throws java.lang.Exception
Parameters:
x - The feature to be added to the Edge attribute
y - The feature to be added to the Edge attribute
Throws:
java.lang.Exception - Description of Exception

addEdge

public void addEdge(Edge e)
             throws java.lang.Exception
Parameters:
e - The feature to be added to the Edge attribute
Throws:
java.lang.Exception - Description of Exception

contains

public boolean contains(Vertex x)
Returns true if vertex x is present in the graph.

Parameters:
x - Description of Parameter
Returns:
Description of the Returned Value

removeEdge

public Edge removeEdge(Vertex in,
                       Vertex out)
Remove directed edge from the graph.

Parameters:
in - First vertex.
out - Secon vertex.
Returns:
The edge that have been removed. null if the edge was not present.

dump

public void dump()
Description of the Method


SourceForge.net Logo