diva.pod.lwgraph
Class Topology

java.lang.Object
  extended by diva.pod.lwgraph.Topology

public final class Topology
extends Object

The primitive data structure underlying a light-weight graph. Clients can instantiate and use this class directly if they don't mind dealing with integer indices to represent nodes and edges. Doing so is recommended only if large graphs are being constructed with no need for information attached to the nodes and/or edges. Note that very little error checking is performed in this class. If information needs to be attached to nodes or edges, then the LightweightGraph class is recommended instead.

Version:
$Revision: 1.4 $
Author:
John Reekie

Constructor Summary
Topology()
          Create a new, empty, topology
 
Method Summary
 void connect(int edge, int tail, int head)
          Connect the tail and head nodes, using the given edge id.
 int find(int firstedge, int tail, int head)
          Find an edge between the given tail and head nodes, starting from the given edge.
 int getHead(int edge)
          Get the head node of the given edge.
 int getMaxEdgeId()
          Get the maximum edge id.
 int getMaxNodeId()
          Get the highest node id known
 int getTail(int edge)
          Get the tail node of the given edge.
 void removeEdge(int edge)
          Remove the given edge.
 void reverse()
          Reverse the graph
 void setHead(int edge, int head)
          Set the head node of the given edge.
 void setTail(int edge, int tail)
          Set the tail node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Topology

public Topology()
Create a new, empty, topology

Method Detail

connect

public void connect(int edge,
                    int tail,
                    int head)
Connect the tail and head nodes, using the given edge id. The amount is storage used by this class depends on the maximum edge id, so edge ids should be alloctated by the caller from zero on up, if possible. More than one edge between two nodes is allowed. If an edge is to be connected at one end only, use an id of -1 for the other end.


find

public int find(int firstedge,
                int tail,
                int head)
Find an edge between the given tail and head nodes, starting from the given edge. Return -1 if none is found.


getMaxEdgeId

public int getMaxEdgeId()
Get the maximum edge id.


getHead

public int getHead(int edge)
Get the head node of the given edge.


getMaxNodeId

public int getMaxNodeId()
Get the highest node id known


getTail

public int getTail(int edge)
Get the tail node of the given edge.


removeEdge

public void removeEdge(int edge)
Remove the given edge.


reverse

public void reverse()
Reverse the graph


setHead

public void setHead(int edge,
                    int head)
Set the head node of the given edge. The edge and node *must* have already been introduced to the graph with the connect() method. The node id can be -1 to "disconnect" the edge.


setTail

public void setTail(int edge,
                    int tail)
Set the tail node. The edge and node *must* have already been introduced to the graph with the connect() method. The node id can be -1 to "disconnect" the edge.



Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.