dk.brics.xact.analysis.flowgraph
Class Graph<Nodetype,Edgetype>

java.lang.Object
  extended by dk.brics.xact.analysis.flowgraph.Graph<Nodetype,Edgetype>
Direct Known Subclasses:
FlowGraph

public class Graph<Nodetype,Edgetype>
extends Object

Generic directed multigraph.


Constructor Summary
Graph()
          Constructs an empty graph.
 
Method Summary
 void addAll(Graph<Nodetype,Edgetype> other)
          Adds all nodes and edges from another graph to this one.
 void addEdge(Nodetype from, Nodetype to, Edgetype data)
          Adds an edge between two nodes in the graph.
 void addEntry(Nodetype node)
          Marks an existing node as an entry node of the graph.
 void addNode(Nodetype node)
          Adds the given node to the graph.
 void clearEdges()
          Removes all edges.
 boolean containsNode(Nodetype node)
          Checks whether the graph contains the given node.
 Set<Nodetype> getEntries()
          Returns the set of entry nodes of the graph.
 Set<Edge<Nodetype,Edgetype>> getInEdges(Nodetype node)
          Returns the predecessors of the given node.
 Set<Nodetype> getNodes()
          Returns the set of nodes.
 int getNumberOfEdges()
          Returns the total number of edges.
 Set<Edge<Nodetype,Edgetype>> getOutEdges(Nodetype node)
          Returns the successors of the given node.
 void removeEdge(Edge<Nodetype,Edgetype> edge)
          Removes an existing edge between two nodes in the graph.
 void removeEntry(Nodetype node)
          Removes an entry node of the graph.
 void removeNode(Nodetype node)
          Removes the given node from the graph.
 void removeOutEdges(Nodetype node)
          Removes all outgoing edges from the given node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Graph

public Graph()
Constructs an empty graph.

Method Detail

addAll

public void addAll(Graph<Nodetype,Edgetype> other)
Adds all nodes and edges from another graph to this one.


addEdge

public void addEdge(Nodetype from,
                    Nodetype to,
                    Edgetype data)
Adds an edge between two nodes in the graph.

Throws:
NoSuchElementException - if either of the nodes does not exist in the graph

addEntry

public void addEntry(Nodetype node)
Marks an existing node as an entry node of the graph.

Throws:
NoSuchElementException - if the node does not exist

addNode

public void addNode(Nodetype node)
Adds the given node to the graph.


clearEdges

public void clearEdges()
Removes all edges.


containsNode

public boolean containsNode(Nodetype node)
Checks whether the graph contains the given node.


getEntries

public Set<Nodetype> getEntries()
Returns the set of entry nodes of the graph.


getInEdges

public Set<Edge<Nodetype,Edgetype>> getInEdges(Nodetype node)
Returns the predecessors of the given node.

Throws:
NoSuchElementException - if the node does not exist in the graph

getNodes

public Set<Nodetype> getNodes()
Returns the set of nodes.


getNumberOfEdges

public int getNumberOfEdges()
Returns the total number of edges.


getOutEdges

public Set<Edge<Nodetype,Edgetype>> getOutEdges(Nodetype node)
Returns the successors of the given node.

Throws:
NoSuchElementException - if the node does not exist in the graph

removeEdge

public void removeEdge(Edge<Nodetype,Edgetype> edge)
Removes an existing edge between two nodes in the graph.

Throws:
NoSuchElementException - if the edge does not exist

removeEntry

public void removeEntry(Nodetype node)
Removes an entry node of the graph.

Throws:
NoSuchElementException - if the node does not exist

removeNode

public void removeNode(Nodetype node)
Removes the given node from the graph. All edges to or from this node are also removed.

Throws:
NoSuchElementException - if the node does not exist in the graph

removeOutEdges

public void removeOutEdges(Nodetype node)
Removes all outgoing edges from the given node.



Copyright © 2005-2008 Aarhus University.