com.mizar.graphtheory
Class Graph

java.lang.Object
  extended by com.mizar.graphtheory.Graph
All Implemented Interfaces:
java.io.Serializable

public class Graph
extends java.lang.Object
implements java.io.Serializable

See Also:
Serialized Form

Constructor Summary
Graph()
           
Graph(double precision)
           
 
Method Summary
 long addEdge(Edge newEdge)
           
 void addNode(Node toAdd)
           
 Polyline buildPolyline(java.util.Collection<Edge> polylines)
           
 java.util.List<Edge> chain(Edge startEdge)
          The method returns an ordered list of edges starting with startEdge and ending at the first fork or at the end of the list of edges.
 java.util.List<Edge> chain(long startEdgeId)
           
 java.util.List<java.util.List<Edge>> chains(Edge startEdge)
          This is probably not a very efficient algorithm but it should be okay for small datasets such as streets of a common name.
 void clearWalk()
           
 void condenseTopology()
          One step beyond simplify Topology Identifies duplicate Edges, edges which cover the same area but are not the same preciscely
 Node getClosestNode(Node node)
          Finds the closest node in the network to node.
 Node getClosestNode(Point xy)
           
 Edge getEdge(long edgeId)
           
 java.util.TreeSet<Edge> getEdges()
           
 java.lang.String getEdgeWkt()
           
 java.util.ArrayList<Face> getFaces()
           
 java.util.ArrayList<java.util.ArrayList<Edge>> getForks()
           
 java.util.ArrayList<Node> getLeafNodes()
          Returns all leaf nodes.
 java.util.ArrayList<Node> getLeafNodes(int subNetId)
          Returns leaf nose for the given subnetwork.
 double[] getMBR()
          Deprecated.  
 Node getNode(Point location, int userId)
          if a node for location exists, return that else return a new node for location
 java.util.TreeSet<Node> getNodes()
           
 int getNumSubNetworks()
           
 double getPrecision()
           
 Node getStartNode(java.util.ArrayList<Node> leafList)
          Determines if there is a unique start point to this network
 boolean hasCycle()
           
 boolean isIsWalked()
           
 void mergeNodes(double newPrecision)
           
 boolean pathExists(Node a, Node b)
          Checks if there is a path between a and b.
 void removeEdge(Edge e)
           
 void removeSubNetwork(int id)
           
 void setEdges(java.util.TreeSet<Edge> edges)
           
 void setFaces(java.util.ArrayList<Face> faces)
           
 void setNodes(java.util.TreeSet<Node> nodes)
           
 void setPrecision(double precision)
           
 void simplifyTopology()
          Minimize the topology by joining edges that connect together Merged edges must be connected by a 2-edge Node and have the same L/R face
 void snapEdges()
          Forcibly snap all edges to their associated node
 void walk()
          Walks through the network starting at the first point inserted WARNING: Not a minimum distance walk
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Graph

public Graph()

Graph

public Graph(double precision)
Method Detail

pathExists

public boolean pathExists(Node a,
                          Node b)
Checks if there is a path between a and b.

Parameters:
a -
b -
Returns:

getEdgeWkt

public java.lang.String getEdgeWkt()

snapEdges

public void snapEdges()
Forcibly snap all edges to their associated node


mergeNodes

public void mergeNodes(double newPrecision)

condenseTopology

public void condenseTopology()
                      throws GeometryException
One step beyond simplify Topology Identifies duplicate Edges, edges which cover the same area but are not the same preciscely

Throws:
GeometryException

simplifyTopology

public void simplifyTopology()
Minimize the topology by joining edges that connect together Merged edges must be connected by a 2-edge Node and have the same L/R face


hasCycle

public boolean hasCycle()

walk

public void walk()
Walks through the network starting at the first point inserted WARNING: Not a minimum distance walk


clearWalk

public void clearWalk()

getEdge

public Edge getEdge(long edgeId)
Parameters:
edgeId - the identified for the edge of interest
Returns:
an edge with edgeId, null if not found

chains

public java.util.List<java.util.List<Edge>> chains(Edge startEdge)
This is probably not a very efficient algorithm but it should be okay for small datasets such as streets of a common name.

Parameters:
startEdge -
Returns:

chain

public java.util.List<Edge> chain(long startEdgeId)
Parameters:
startEdgeId - an edgeId to start chaining from
Returns:
a list of Edge instances

chain

public java.util.List<Edge> chain(Edge startEdge)
The method returns an ordered list of edges starting with startEdge and ending at the first fork or at the end of the list of edges.

Parameters:
startEdge -
Returns:

addNode

public void addNode(Node toAdd)

removeSubNetwork

public void removeSubNetwork(int id)

buildPolyline

public Polyline buildPolyline(java.util.Collection<Edge> polylines)
                       throws java.lang.Exception
Throws:
java.lang.Exception

removeEdge

public void removeEdge(Edge e)

addEdge

public long addEdge(Edge newEdge)
             throws ConnectivityException
Throws:
ConnectivityException

getNode

public Node getNode(Point location,
                    int userId)
if a node for location exists, return that else return a new node for location

Parameters:
location - point to test
Returns:
a node, for sure

getClosestNode

public Node getClosestNode(Node node)
                    throws ConnectivityException
Finds the closest node in the network to node.

Parameters:
node -
Returns:
Throws:
ConnectivityException

getClosestNode

public Node getClosestNode(Point xy)
                    throws ConnectivityException
Throws:
ConnectivityException

getLeafNodes

public java.util.ArrayList<Node> getLeafNodes(int subNetId)
Returns leaf nose for the given subnetwork.

Parameters:
subNetId - sub network id, or 0 to get all
Returns:

getLeafNodes

public java.util.ArrayList<Node> getLeafNodes()
Returns all leaf nodes.

Returns:

isIsWalked

public boolean isIsWalked()

getNumSubNetworks

public int getNumSubNetworks()

getMBR

@Deprecated
public double[] getMBR()
Deprecated. 

It looks like no one uses this. If it shows up on a deprecation warning notify Millman

Returns:

getStartNode

public Node getStartNode(java.util.ArrayList<Node> leafList)
Determines if there is a unique start point to this network

Parameters:
leafList -
Returns:
The start node if only one exists, otherwise return null

getForks

public java.util.ArrayList<java.util.ArrayList<Edge>> getForks()

setFaces

public void setFaces(java.util.ArrayList<Face> faces)

getFaces

public java.util.ArrayList<Face> getFaces()

setPrecision

public void setPrecision(double precision)

getPrecision

public double getPrecision()

setEdges

public void setEdges(java.util.TreeSet<Edge> edges)

getEdges

public java.util.TreeSet<Edge> getEdges()

setNodes

public void setNodes(java.util.TreeSet<Node> nodes)

getNodes

public java.util.TreeSet<Node> getNodes()