uk.ed.inf.graph.impl
Class Subgraph

java.lang.Object
  extended by uk.ed.inf.graph.impl.Subgraph
All Implemented Interfaces:
IBasicGraph<Node,Edge>, IBasicSubgraph<Node,Edge>, IUndirectedSubgraph<Node,Edge>

public final class Subgraph
extends java.lang.Object
implements IUndirectedSubgraph<Node,Edge>


Constructor Summary
Subgraph(Graph superGraph)
           
 
Method Summary
(package private)  void addConnectedEdge(Edge edge)
           
(package private)  void addDanglingEdge(Edge edge)
           
(package private)  void addNode(Node node)
           
 boolean containsConnection(IBasicPair<? extends Node,? extends Edge> ends)
          Tests if the graph has an edge between the defined ends.
 boolean containsConnection(Node thisNode, Node thatNode)
          Tests if the graph contains an edge connecting these nodes.
 boolean containsEdge(Edge edge)
          Tests if the graph contains the edge.
 boolean containsEdge(int edgeIdx)
          Tests if the graph contains the edge of the given index.
 boolean containsNode(int nodeIdx)
          Tests if the graph contains the node with the given index number.
 boolean containsNode(Node node)
          Tests if this node exists in the graph.
 java.util.Iterator<Edge> edgeIterator()
          Get an iterator that traverses all the edges in this graph.
 Edge getEdge(int edgeIdx)
          Get the edge with this index.
 Node getNode(int nodeIdx)
          Get the node matching the nodeIdx.
 int getNumEdges()
          Get the number of edges in the graph.
 int getNumNodes()
          Get the number of nodes in the graph.
 Graph getSuperGraph()
           
 boolean isConsistentSnapShot()
           
 boolean isInducedSubgraph()
           
 java.util.Iterator<Node> nodeIterator()
          Get an iterator that traverses all the nodes in this graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Subgraph

Subgraph(Graph superGraph)
Method Detail

isInducedSubgraph

public boolean isInducedSubgraph()
Specified by:
isInducedSubgraph in interface IBasicSubgraph<Node,Edge>

getSuperGraph

public Graph getSuperGraph()
Specified by:
getSuperGraph in interface IBasicSubgraph<Node,Edge>

containsNode

public boolean containsNode(Node node)
Description copied from interface: IBasicGraph
Tests if this node exists in the graph.

Specified by:
containsNode in interface IBasicGraph<Node,Edge>
Parameters:
node - to be tested.
Returns:
True if the graph contains the node, false otherwise.

containsConnection

public boolean containsConnection(Node thisNode,
                                  Node thatNode)
Description copied from interface: IBasicGraph
Tests if the graph contains an edge connecting these nodes. Ignores the direction of the edge.

Specified by:
containsConnection in interface IBasicGraph<Node,Edge>
Parameters:
thisNode - a node to test.
thatNode - the other node to test.
Returns:
true if the edge exists, false otherwise.

containsEdge

public boolean containsEdge(Edge edge)
Description copied from interface: IBasicGraph
Tests if the graph contains the edge.

Specified by:
containsEdge in interface IBasicGraph<Node,Edge>
Parameters:
edge - the edge to test.
Returns:
true if the edge exists in the graph, false otherwise.

edgeIterator

public java.util.Iterator<Edge> edgeIterator()
Description copied from interface: IBasicGraph
Get an iterator that traverses all the edges in this graph. No traversal order is guaranteed.

Specified by:
edgeIterator in interface IBasicGraph<Node,Edge>
Returns:
The edge iterator, guaranteed to be non-null.

nodeIterator

public java.util.Iterator<Node> nodeIterator()
Description copied from interface: IBasicGraph
Get an iterator that traverses all the nodes in this graph. The traversal order is not guaranteed, but all nodes will be traversed.

Specified by:
nodeIterator in interface IBasicGraph<Node,Edge>
Returns:
The node iterator, guaranteed to be non-null.

getNumEdges

public int getNumEdges()
Description copied from interface: IBasicGraph
Get the number of edges in the graph.

Specified by:
getNumEdges in interface IBasicGraph<Node,Edge>
Returns:
The number of edges.

getNumNodes

public int getNumNodes()
Description copied from interface: IBasicGraph
Get the number of nodes in the graph.

Specified by:
getNumNodes in interface IBasicGraph<Node,Edge>
Returns:
The number of nodes.

addNode

void addNode(Node node)

addConnectedEdge

void addConnectedEdge(Edge edge)

addDanglingEdge

void addDanglingEdge(Edge edge)

containsEdge

public boolean containsEdge(int edgeIdx)
Description copied from interface: IBasicGraph
Tests if the graph contains the edge of the given index.

Specified by:
containsEdge in interface IBasicGraph<Node,Edge>
Parameters:
edgeIdx - the index to test.
Returns:
true if matching edge can be found, false otherwise.

containsNode

public boolean containsNode(int nodeIdx)
Description copied from interface: IBasicGraph
Tests if the graph contains the node with the given index number.

Specified by:
containsNode in interface IBasicGraph<Node,Edge>
Parameters:
nodeIdx - The index number of the node.
Returns:
True if the graph contains the node, false otherwise.

getEdge

public Edge getEdge(int edgeIdx)
Description copied from interface: IBasicGraph
Get the edge with this index.

Specified by:
getEdge in interface IBasicGraph<Node,Edge>
Parameters:
edgeIdx - The index of the edge.
Returns:
The edge matching the index.

getNode

public Node getNode(int nodeIdx)
Description copied from interface: IBasicGraph
Get the node matching the nodeIdx.

Specified by:
getNode in interface IBasicGraph<Node,Edge>
Parameters:
nodeIdx - the node index to lookup.
Returns:
the node matching the index. Cannot be null.

isConsistentSnapShot

public boolean isConsistentSnapShot()
Specified by:
isConsistentSnapShot in interface IBasicSubgraph<Node,Edge>

containsConnection

public boolean containsConnection(IBasicPair<? extends Node,? extends Edge> ends)
Description copied from interface: IBasicGraph
Tests if the graph has an edge between the defined ends.

Specified by:
containsConnection in interface IBasicGraph<Node,Edge>
Parameters:
ends - the ends of the edge to test.
Returns:
true if the edge exists in the graph, false otherwise.