jwo.landserf.structure.msn
Class GraphNetwork

java.lang.Object
  extended byjwo.landserf.structure.msn.GraphNetwork

public class GraphNetwork
extends Object

Structure to hold a Wolf-Pfaltz Surface Network for characterising surface topology.

Version:
2.2, 16th August, 2003.
Author:
Jo Wood

Constructor Summary
GraphNetwork()
          Creates an empty network graph.
GraphNetwork(float tolerance)
          Creates an empty network graph.
GraphNetwork(float tolerance, GISFrame gisFrame)
          Creates an empty network graph.
GraphNetwork(String msnText)
          Creates a network graph from the given ASCII representation.
 
Method Summary
 void addEdge(GISVector path, int type1, int type2, float z1, float z2)
          Adds a given edge to the network.
 void addEdge(GraphNode node1, GraphNode node2)
          Adds a new edge defined by the given nodes to the network.
 void addJunction(GraphNode junctionNode, GraphEdge newEdge)
          Adds a new junction to the list stored by the network.
 void addPath(GraphEdge edge, GISVector path)
          Adds a given edge path to the master list of paths stored by this class.
 void appendJunction(GraphNode junctionNode, GraphEdge newEdge)
          Adds a new edge to an existing junction.
 int countNumGraphs()
          Counts and reports the number of disconnected subgraphs.
 Vector getChannels()
          Reports a list of all the channels in the network.
 String getEdgeList()
          Reports all the edges (ridges and channels) associated with the graph.
 Vector getEdgePaths()
          Reports a list of all the edge paths.
 Vector getEdges()
          Returns all the edges that make up the network.
 int getIDCounter()
          Reports the current ID counter.
 Vector getNodes()
          Reports the list of nodes stored in the network.
 int getNumEdges()
          Reports the number of edges in the network.
 String getPassList()
          Reports all the passes associated with the graph.
 GISVector getPath(GraphEdge edge)
          Reports the path associated with the given edge.
 String getPeakList()
          Reports all the peaks associated with the graph.
 String getPitList()
          Reports all the pits associated with the graph.
 Vector getRidges()
          Reports a list of all the ridges in the network.
 float getTolerance()
          Reports the node-snapping tolerance used when linking edges to nodes.
 VectorMap getVectorMap()
          Converts the Metric Surface Network into a vector map for display.
 VectorMap getVectorMap(VectorMap vectMap)
          Fills the given vector map with a representation of the the Metric Surface Network.
 void incIDCounter()
          Increments the current ID counter.
 boolean readFile(String fileName, int format)
          Opens a metric surface network file.
 boolean removeEdge(GraphEdge edge)
          Removes the given edge from the network.
 boolean removeEdge(GraphNode nodeToRemove)
          Removes all the edges connected to the given node as well as the node itself.
 boolean removeEdge(GraphNode node1, GraphNode node2)
          Removes the first edge connecting the given nodes.
 boolean replacePath(GraphEdge edge, GISVector newPath)
          Replaces the path associated with the given edge by the given path.
 void resetIDs()
          Resets the IDs of all nodes in the network.
 void snapLines(float snapTolerance)
          Snaps lines of identical attribute to one another.
 String toString()
          Describes the network.
 void updateFromText(String msnText)
          Converts the given string into a surface network.
 boolean writeFile(String fileName, int format)
          Saves a version of the graph as a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GraphNetwork

public GraphNetwork()
Creates an empty network graph.


GraphNetwork

public GraphNetwork(String msnText)
Creates a network graph from the given ASCII representation. The ASCII string should be in the form created by getPitList(), getPassList(), get PeakList() and getEdgeList().

Parameters:
msnText - Lines of text reprenting network topology.

GraphNetwork

public GraphNetwork(float tolerance)
Creates an empty network graph.

Parameters:
tolerance - Node snapping tolerance.

GraphNetwork

public GraphNetwork(float tolerance,
                    GISFrame gisFrame)
Creates an empty network graph.

Parameters:
tolerance - Node snapping tolerance.
Method Detail

addEdge

public void addEdge(GISVector path,
                    int type1,
                    int type2,
                    float z1,
                    float z2)
Adds a given edge to the network.

Parameters:
path - Vector path connecting nodes.
type1 - Type of node at one end.
type2 - Type of node at the other end.
z1 - Height at one end.
z2 - Height at the other end.

addEdge

public void addEdge(GraphNode node1,
                    GraphNode node2)
Adds a new edge defined by the given nodes to the network.

Parameters:
node1 - First node in edge.
node2 - Second node in edge.

removeEdge

public boolean removeEdge(GraphEdge edge)
Removes the given edge from the network.

Parameters:
edge - Edge to remove.
Returns:
Returns true if edge sucessfully removed.

removeEdge

public boolean removeEdge(GraphNode node1,
                          GraphNode node2)
Removes the first edge connecting the given nodes. Note that the integrity of the network is not checked after removing the edge.

Parameters:
node1 - First node in edge.
node2 - Second node in edge.
Returns:
Returns true if edge sucessfully removed, otherwise false.

removeEdge

public boolean removeEdge(GraphNode nodeToRemove)
Removes all the edges connected to the given node as well as the node itself. Note that the integrity of the network is not checked after removing edges and node.

Parameters:
nodeToRemove - Node to search from and remove.
Returns:
Returns true if any edges sucessfully removed, otherwise false.

addJunction

public void addJunction(GraphNode junctionNode,
                        GraphEdge newEdge)
Adds a new junction to the list stored by the network.

Parameters:
junctionNode - Node at centre of junction.
newEdge - New edge to add to junction.

appendJunction

public void appendJunction(GraphNode junctionNode,
                           GraphEdge newEdge)
Adds a new edge to an existing junction.

Parameters:
junctionNode - Node at centre of junction.
newEdge - New edge to add to junction.

addPath

public void addPath(GraphEdge edge,
                    GISVector path)
Adds a given edge path to the master list of paths stored by this class.

Parameters:
edge - Edge with which to associate paths.
path - Geometric path associated with edge.

replacePath

public boolean replacePath(GraphEdge edge,
                           GISVector newPath)
Replaces the path associated with the given edge by the given path.

Parameters:
edge - Edge containing path to replace.
newPath - New geometric path to replace existing one.
Returns:
True if path successfully replaced.

getPath

public GISVector getPath(GraphEdge edge)
Reports the path associated with the given edge.

Parameters:
edge - Edge from which to extract path geometry.
Returns:
Path geometry associated with the given edge, or null if edge not found.

getEdges

public Vector getEdges()
Returns all the edges that make up the network.

Returns:
List of all edges in the network.

getEdgePaths

public Vector getEdgePaths()
Reports a list of all the edge paths. Each path is a GIS vector storing the geometry of the connection between two nodes.

Returns:
Collection of edge paths.

getChannels

public Vector getChannels()
Reports a list of all the channels in the network. Each channel is a GraphEdge connecting two GraphNodes.

Returns:
List of channel edges in the network.

getRidges

public Vector getRidges()
Reports a list of all the ridges in the network. Each ridge is a GraphEdge connecting two GraphNodes.

Returns:
List of ridge edges in the network.

getVectorMap

public VectorMap getVectorMap()
Converts the Metric Surface Network into a vector map for display.


getVectorMap

public VectorMap getVectorMap(VectorMap vectMap)
Fills the given vector map with a representation of the the Metric Surface Network.

Parameters:
vectMap - VectorMap to fill.

getIDCounter

public int getIDCounter()
Reports the current ID counter. This can be used for counting sub-graphs in the network.

Returns:
Current ID counter.

incIDCounter

public void incIDCounter()
Increments the current ID counter. This is used when adding new nodes to the graph.


getTolerance

public float getTolerance()
Reports the node-snapping tolerance used when linking edges to nodes.

Returns:
Node tolerance in spatial units.

toString

public String toString()
Describes the network.

Returns:
Textual description of the networks.

writeFile

public boolean writeFile(String fileName,
                         int format)
Saves a version of the graph as a file.

Parameters:
fileName - Name of file to save.
format - File format to save.

readFile

public boolean readFile(String fileName,
                        int format)
Opens a metric surface network file.

Parameters:
fileName - Name of file to open.
format - File format to open.

countNumGraphs

public int countNumGraphs()
Counts and reports the number of disconnected subgraphs.

Returns:
Number of disconnected subgraphs.

getPitList

public String getPitList()
Reports all the pits associated with the graph. Uses the format X pitID xCoord yCoord zCoord 0 (universal) 1 (internal).

Returns:
List of all pits in graph.

getPassList

public String getPassList()
Reports all the passes associated with the graph. Uses the format X passID xCoord yCoord zCoord.

Returns:
List of all passes in graph.

getPeakList

public String getPeakList()
Reports all the peaks associated with the graph. Uses the format X peakID xCoord yCoord zCoord 0 (universal) 1 (internal).

Returns:
List of all peaks in graph.

getEdgeList

public String getEdgeList()
Reports all the edges (ridges and channels) associated with the graph. Uses the format E passID pit1ID pit2ID peak1ID peak2ID

Returns:
List of all edges in graph.

getNumEdges

public int getNumEdges()
Reports the number of edges in the network.

Returns:
Number of edges in the network.

updateFromText

public void updateFromText(String msnText)
Converts the given string into a surface network. Text should be in the form created by getPitList(), getPeakList() etc.

Parameters:
msnText - Text representing msn.

getNodes

public Vector getNodes()
Reports the list of nodes stored in the network.

Returns:
List of nodes used to construct edges in the network.

resetIDs

public void resetIDs()
Resets the IDs of all nodes in the network.


snapLines

public void snapLines(float snapTolerance)
Snaps lines of identical attribute to one another.

Parameters:
snapTolerance - Distance within which, adjacent lines are snapped.


Copyright Jo Wood, 1996-2005, last modified, 11th March, 2005