gps.network.graph
Class Graph

java.lang.Object
  extended by gps.network.graph.Graph

public class Graph
extends java.lang.Object

graph is an object representing network topology. this file is based on KOM / LetsQoS Topology Conversion Tools. Two ways to add a node: Instanciate a Node object and call graph.addNode() to get back the key of the node. Or call graph.newNode() to get back a new node that is already added to the graph. Same for adding new links.

Author:
Oliver Heckmann

Constructor Summary
Graph()
          Creates new Graph
 
Method Summary
 int addLink(Link l)
          add link
 int addNode(Node n)
          add a node to the graph
static Graph fromALTFile(java.io.BufferedReader r)
          Read from a file in the ALT topology file format
static Graph fromALTFile(java.io.File file)
          Read from a file in the ALT topology file format
static Graph fromALTFile(java.lang.String filename)
          Read from a file in the ALT topology file format
static Graph fromBRITEFile(java.io.BufferedReader r)
          Read from a file in the BRITE topology file format
static Graph fromBRITEFile(java.io.File file)
          Read from a file in the BRITE topology file format
static Graph fromBRITEFile(java.lang.String filename)
          Read from a file in the BRITE topology file format
static Graph fromCSVFile(java.io.BufferedReader r)
          Read from a file in the CVS topology file format
static Graph fromCSVFile(java.io.File file)
          Read from a file in the CVS topology file format
static Graph fromCSVFile(java.lang.String filename)
          Read from a file in the CVS topology file format
static Graph fromGMLFile(java.io.BufferedInputStream r)
          Read from a file in the GML topology file format
static Graph fromGMLFile(java.io.File file)
          Read from a file in the GML topology file format
static Graph fromGMLFile(java.lang.String filename)
          Read from a file in the GML topology file format
static Graph fromGTTSFile(java.io.BufferedReader r)
          Read from a file in the GTTS topology file format
static Graph fromGTTSFile(java.io.File file)
          Read from a file in the GTTS topology file format
static Graph fromGTTSFile(java.lang.String filename)
          Read from a file in the GTTS topology file format
static Graph fromINETFile(java.io.BufferedReader r)
          Read from a file in the INET topology file format
static Graph fromINETFile(java.io.File file)
          Read from a file in the INET topology file format
static Graph fromINETFile(java.lang.String filename)
          Read from a file in the INET topology file format
static Graph fromNLANRFile(java.io.BufferedReader r)
          Read from a file in the NLANR topology file format
static Graph fromNLANRFile(java.io.File file)
          Read from a file in the NLANR topology file format
static Graph fromNLANRFile(java.lang.String filename)
          Read from a file in the NLANR topology file format
static Graph fromTIERSFile(java.io.BufferedReader r)
          Read from a file in the TIERS topology file format
static Graph fromTIERSFile(java.io.File file)
          Read from a file in the TIERS topology file format
static Graph fromTIERSFile(java.lang.String filename)
          Read from a file in the TIERS topology file format
 Link[] getAllLinks()
          gets all links
 Node[] getAllNodes()
          gets all nodes
 java.lang.String getComment()
          gets comment
 java.lang.String getCreator()
          gets creator
 java.lang.String getGraphFile()
          gets file path
 Link getLink(int key)
          gets link
 Node getNode(int key)
          Retrieve a node
 int getNumberOfLinks()
          gets number of links
 int getNumberOfNodes()
          gets number of nodes
 boolean isValid()
          check validity
static void main(java.lang.String[] args)
          command line converter
 Link newDirectedLink(int fromNode, int toNode)
          adds directed link
 Node newNode()
          creates a new Node that is already element of the graph (no need to call addNode())
 Link newUndirectedLink(int fromNode, int toNode)
          adds undirected link
 void setComment(java.lang.String comment)
          sets comment
 void setCreator(java.lang.String creator)
          sets creator
 void setGraphFile(java.lang.String f)
          sets file path
 java.lang.String toString()
          converting the graph into a human readable string
 void writeToGML(java.io.File f)
          write to a file in the GML topology file format
 void writeToGML(java.lang.String filename)
          write to a file in the GML topology file format
 void writeToNS2(java.io.File f)
          write to a file in the NS2 script
 void writeToNS2(java.lang.String filename)
          write to a file in the NS2 script
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Graph

public Graph()
Creates new Graph

Method Detail

getGraphFile

public java.lang.String getGraphFile()
gets file path

Returns:
file path

setGraphFile

public void setGraphFile(java.lang.String f)
sets file path

Parameters:
f - file path

isValid

public boolean isValid()
check validity

Returns:
true if valid

getComment

public java.lang.String getComment()
gets comment

Returns:
comment

setComment

public void setComment(java.lang.String comment)
sets comment

Parameters:
comment - new comment

getCreator

public java.lang.String getCreator()
gets creator

Returns:
creator

setCreator

public void setCreator(java.lang.String creator)
sets creator

Parameters:
creator - new creator

addNode

public int addNode(Node n)
add a node to the graph

Parameters:
n - new node
Returns:
node id

newNode

public Node newNode()
creates a new Node that is already element of the graph (no need to call addNode())

Returns:
the new node

getNode

public Node getNode(int key)
Retrieve a node

Parameters:
key - node id
Returns:
node

getNumberOfNodes

public int getNumberOfNodes()
gets number of nodes

Returns:
number of nodes

newUndirectedLink

public Link newUndirectedLink(int fromNode,
                              int toNode)
adds undirected link

Parameters:
fromNode - source node
toNode - destination node
Returns:
link

newDirectedLink

public Link newDirectedLink(int fromNode,
                            int toNode)
adds directed link

Parameters:
fromNode - source node
toNode - destination node
Returns:
link

addLink

public int addLink(Link l)
add link

Parameters:
l - link
Returns:
the key of the link

getLink

public Link getLink(int key)
gets link

Parameters:
key - key of the link
Returns:
link

getNumberOfLinks

public int getNumberOfLinks()
gets number of links

Returns:
number of links

getAllLinks

public Link[] getAllLinks()
gets all links

Returns:
array of link

getAllNodes

public Node[] getAllNodes()
gets all nodes

Returns:
array of nodes

toString

public java.lang.String toString()
converting the graph into a human readable string

Overrides:
toString in class java.lang.Object
Returns:
string description of the graph

fromGMLFile

public static Graph fromGMLFile(java.lang.String filename)
                         throws java.io.IOException,
                                GraphException
Read from a file in the GML topology file format

Parameters:
filename - file name
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromGMLFile

public static Graph fromGMLFile(java.io.File file)
                         throws java.io.IOException,
                                GraphException
Read from a file in the GML topology file format

Parameters:
file - File object
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromGMLFile

public static Graph fromGMLFile(java.io.BufferedInputStream r)
                         throws java.io.IOException,
                                GraphException
Read from a file in the GML topology file format

Parameters:
r - buffered input stream
Returns:
graph object
Throws:
java.io.IOException
GraphException

writeToGML

public void writeToGML(java.lang.String filename)
                throws java.io.IOException,
                       GraphException
write to a file in the GML topology file format

Parameters:
filename - file name
Throws:
java.io.IOException
GraphException

writeToGML

public void writeToGML(java.io.File f)
                throws java.io.IOException,
                       GraphException
write to a file in the GML topology file format

Parameters:
f - File object
Throws:
java.io.IOException
GraphException

writeToNS2

public void writeToNS2(java.lang.String filename)
                throws java.io.IOException,
                       GraphException
write to a file in the NS2 script

Parameters:
filename - file name
Throws:
java.io.IOException
GraphException

writeToNS2

public void writeToNS2(java.io.File f)
                throws java.io.IOException,
                       GraphException
write to a file in the NS2 script

Parameters:
f - File object
Throws:
java.io.IOException
GraphException

fromBRITEFile

public static Graph fromBRITEFile(java.lang.String filename)
                           throws java.io.IOException,
                                  GraphException
Read from a file in the BRITE topology file format

Parameters:
filename - file name
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromBRITEFile

public static Graph fromBRITEFile(java.io.File file)
                           throws java.io.IOException,
                                  GraphException
Read from a file in the BRITE topology file format

Parameters:
file - File object
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromBRITEFile

public static Graph fromBRITEFile(java.io.BufferedReader r)
                           throws java.io.IOException,
                                  GraphException
Read from a file in the BRITE topology file format

Parameters:
r - buffered reader
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromALTFile

public static Graph fromALTFile(java.lang.String filename)
                         throws java.io.IOException,
                                GraphException
Read from a file in the ALT topology file format

Parameters:
filename - file name
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromALTFile

public static Graph fromALTFile(java.io.File file)
                         throws java.io.IOException,
                                GraphException
Read from a file in the ALT topology file format

Parameters:
file - File object
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromALTFile

public static Graph fromALTFile(java.io.BufferedReader r)
                         throws java.io.IOException,
                                GraphException
Read from a file in the ALT topology file format

Parameters:
r - buffered reader
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromTIERSFile

public static Graph fromTIERSFile(java.lang.String filename)
                           throws java.io.IOException,
                                  GraphException
Read from a file in the TIERS topology file format

Parameters:
filename - file name
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromTIERSFile

public static Graph fromTIERSFile(java.io.File file)
                           throws java.io.IOException,
                                  GraphException
Read from a file in the TIERS topology file format

Parameters:
file - File object
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromTIERSFile

public static Graph fromTIERSFile(java.io.BufferedReader r)
                           throws java.io.IOException,
                                  GraphException
Read from a file in the TIERS topology file format

Parameters:
r - buffered reader
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromGTTSFile

public static Graph fromGTTSFile(java.lang.String filename)
                          throws java.io.IOException,
                                 GraphException
Read from a file in the GTTS topology file format

Parameters:
filename - file name
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromGTTSFile

public static Graph fromGTTSFile(java.io.File file)
                          throws java.io.IOException,
                                 GraphException
Read from a file in the GTTS topology file format

Parameters:
file - File object
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromGTTSFile

public static Graph fromGTTSFile(java.io.BufferedReader r)
                          throws java.io.IOException,
                                 GraphException
Read from a file in the GTTS topology file format

Parameters:
r - buffered reader
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromINETFile

public static Graph fromINETFile(java.lang.String filename)
                          throws java.io.IOException,
                                 GraphException
Read from a file in the INET topology file format

Parameters:
filename - file name
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromINETFile

public static Graph fromINETFile(java.io.File file)
                          throws java.io.IOException,
                                 GraphException
Read from a file in the INET topology file format

Parameters:
file - File object
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromINETFile

public static Graph fromINETFile(java.io.BufferedReader r)
                          throws java.io.IOException,
                                 GraphException
Read from a file in the INET topology file format

Parameters:
r - buffered reader
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromNLANRFile

public static Graph fromNLANRFile(java.lang.String filename)
                           throws java.io.IOException,
                                  GraphException
Read from a file in the NLANR topology file format

Parameters:
filename - file name
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromNLANRFile

public static Graph fromNLANRFile(java.io.File file)
                           throws java.io.IOException,
                                  GraphException
Read from a file in the NLANR topology file format

Parameters:
file - File object
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromNLANRFile

public static Graph fromNLANRFile(java.io.BufferedReader r)
                           throws java.io.IOException,
                                  GraphException
Read from a file in the NLANR topology file format

Parameters:
r - buffered reader
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromCSVFile

public static Graph fromCSVFile(java.lang.String filename)
                         throws java.io.IOException,
                                GraphException
Read from a file in the CVS topology file format

Parameters:
filename - file name
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromCSVFile

public static Graph fromCSVFile(java.io.File file)
                         throws java.io.IOException,
                                GraphException
Read from a file in the CVS topology file format

Parameters:
file - File object
Returns:
graph object
Throws:
java.io.IOException
GraphException

fromCSVFile

public static Graph fromCSVFile(java.io.BufferedReader r)
                         throws java.io.IOException,
                                GraphException
Read from a file in the CVS topology file format

Parameters:
r - buffered reader
Returns:
graph object
Throws:
java.io.IOException
GraphException

main

public static void main(java.lang.String[] args)
command line converter

Parameters:
args - arguments