graph
Class Graph

java.lang.Object
  extended bygraph.Graph

public class Graph
extends java.lang.Object


Constructor Summary
Graph(java.io.InputStream stream)
          Initializes a new Graph by parsing the graph-file from the argument stream
Graph(java.io.InputStream stream, java.lang.String nodePrefix, java.lang.String edgePrefix)
          Initializes a new Graph by parsing the graph-file from the argument stream.
 
Method Summary
 Edge addEdge(Node source, Node dest)
          Adds an Edge to the graph.
 Edge addEdge(java.lang.String label, Node source, Node dest)
          Adds an Edge to the graph.
 void addNode(Node node)
          Adds a Node to the graph
 Edge getEdge(java.lang.String label)
          Returns the Edge in the Graph with label given as argument
 java.util.ArrayList getEdges()
          Returns an ArrayList containing all the edges in the graph
 java.util.ArrayList getEdges(java.lang.String property, java.lang.String value)
          Returns an ArrayList containing all the edges in the graph that have a given property with a given value
 Node getNode(java.lang.String label)
          Returns the Node in the Graph with label given as argument
 java.util.ArrayList getNodes()
          Returns an ArrayList containing all the nodes in the graph
 java.util.ArrayList getNodes(java.lang.String property, java.lang.String value)
          Returns an ArrayList containing all the nodes in the graph that have a given property with a given value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Graph

public Graph(java.io.InputStream stream,
             java.lang.String nodePrefix,
             java.lang.String edgePrefix)
Initializes a new Graph by parsing the graph-file from the argument stream. Prefixes each node and edge by strings given as arguments. This is useful when input nodes or edges do not have labels and are automatically assigned a numeric label.

Parameters:
stream - an InputStream to be parsed
nodePrefix - a String to be used as a prefix for the node labels
edgePrefix - a String to be used as a prefix for the edge labels

Graph

public Graph(java.io.InputStream stream)
Initializes a new Graph by parsing the graph-file from the argument stream

Parameters:
stream - InputStream to be parsed
Method Detail

getNode

public Node getNode(java.lang.String label)
Returns the Node in the Graph with label given as argument

Parameters:
label - label of the Node
Returns:
a Node or null if there is no Node with given label

getEdge

public Edge getEdge(java.lang.String label)
Returns the Edge in the Graph with label given as argument

Parameters:
label - label of the Edge
Returns:
an Edge or null if there is no Edge with given label

getNodes

public java.util.ArrayList getNodes()
Returns an ArrayList containing all the nodes in the graph

Returns:
an ArrayList of Nodes.

getEdges

public java.util.ArrayList getEdges()
Returns an ArrayList containing all the edges in the graph

Returns:
an ArrayList of Edges.

addNode

public void addNode(Node node)
Adds a Node to the graph

Parameters:
node - a node to be added.

addEdge

public Edge addEdge(Node source,
                    Node dest)
Adds an Edge to the graph. The new edge goes from source to dest node. A label is generated for the edge.

Parameters:
source - the source node of the edge
dest - the destination node of the edge
Returns:
the newly created Edge.

addEdge

public Edge addEdge(java.lang.String label,
                    Node source,
                    Node dest)
Adds an Edge to the graph. The new edge goes from source to dest node.

Parameters:
label - the label for the new edge
source - the source node of the edge
dest - the destination node of the edge
Returns:
the newly created Edge or null if edge with given label exists.

getNodes

public java.util.ArrayList getNodes(java.lang.String property,
                                    java.lang.String value)
Returns an ArrayList containing all the nodes in the graph that have a given property with a given value

Parameters:
property - a String containing the requested property
value - a String containing the requested value
Returns:
an ArrayList of Nodes.

getEdges

public java.util.ArrayList getEdges(java.lang.String property,
                                    java.lang.String value)
Returns an ArrayList containing all the edges in the graph that have a given property with a given value

Parameters:
property - a String containing the requested property
value - a String containing the requested value
Returns:
an ArrayList of Edges.