gumbo.visualize.data
Class GraphModels

java.lang.Object
  |
  +--gumbo.visualize.data.GraphModels

public final class GraphModels
extends java.lang.Object

Constants and utilities related to graph-like models and their topology.

Version:
$Revision: 1.1 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.

Method Summary
static java.util.Collection findAllEdgePorts(PortModel seed, int seedEnd, int otherEnd, java.util.Collection retVal)
          Returns the port models connected to a seed port, and its subports, through edges with the specified edge end types.
static java.util.Collection findEdgePorts(PortModel seed, int seedEnd, int otherEnd, java.util.Collection retVal)
          Returns the port models connected to a seed port, but not its subports, through edges with the specified edge end types.
static java.util.Collection findEdgeVertices(VertexModel seed, int seedEnd, int otherEnd, java.util.Collection retVal)
          Returns the vertex models connected to a seed vertex through edges with the specified edge end types.
static java.util.Collection findSinks(java.util.Collection parts, java.util.Collection retVal)
          Finds the sink vertex models in a group of part models.
static java.util.Collection findSources(java.util.Collection parts, java.util.Collection retVal)
          Finds the source vertex models in a group of part models.
static boolean hasEdgeVertices(VertexModel seed, int seedEnd, int otherEnd)
          Returns true if any vertex models are connected to a seed vertex through edges with the specified edge end types.
static boolean isSink(VertexModel vert)
          Returns true if a vertex is a sink node (no outgoing edges).
static boolean isSource(VertexModel vert)
          Returns true if a vertex is a source node (no incoming edges).
static java.util.Collection toVertices(java.util.Collection ports, java.util.Collection retVal)
          Gets the vertex models corresponding a group of port models.
static java.util.List traceGraph(VertexModel seedNode, VertexModel pruneNode, boolean traceForward, boolean traceBackward, java.util.List retVal)
          Performs a breadth-first search of a graph starting with a seed node and returning the graph nodes found.
static java.util.List traceList(VertexModel seedNode, VertexModel pruneNode, boolean traceForward, java.util.List retVal)
          Performs a search of a graph starting with a seed node and returning a list of nodes found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toVertices

public static java.util.Collection toVertices(java.util.Collection ports,
                                              java.util.Collection retVal)
Gets the vertex models corresponding a group of port models.

Parameters:
ports - The port models (PortModel). Never null.
retVal - Return value object. The vertex models (VertexModel) in the iterator order of ports. Never null. Can be ports.
Returns:
Reference to retVal. Never null.

findEdgeVertices

public static java.util.Collection findEdgeVertices(VertexModel seed,
                                                    int seedEnd,
                                                    int otherEnd,
                                                    java.util.Collection retVal)
Returns the vertex models connected to a seed vertex through edges with the specified edge end types.

Parameters:
seed - The seed vertex. Never null.
seedEnd - Edge port index associated with the seed end type (such as EdgeModel.INDEX_???_END). >=0.
otherEnd - Edge port index associated with the other end type (such as EdgeModel.INDEX_???_END). >=0.
retVal - Return value object. The connected vertex models (VertexModel), possibly including seed. If not a set, may contain duplicates. Reflects the relative order of the edges. Never null.
Returns:
Reference to retVal. Never null.
Throws:
java.lang.IllegalArgumentException - Seed and other ends are the same.

findEdgePorts

public static java.util.Collection findEdgePorts(PortModel seed,
                                                 int seedEnd,
                                                 int otherEnd,
                                                 java.util.Collection retVal)
Returns the port models connected to a seed port, but not its subports, through edges with the specified edge end types.

Parameters:
seed - The seed port. Never null.
seedEnd - Edge port index associated with the seed end type (such as EdgeModel.INDEX_???_END). >=0.
otherEnd - Edge port index associated with the other end type (such as EdgeModel.INDEX_???_END). >=0.
retVal - Return value object. The connected port models (PortModel), possibly including seed. If not a set, may contain duplicates. Reflects the relative order of the edges. Never null.
Returns:
Reference to retVal. Never null.
Throws:
java.lang.IllegalArgumentException - Seed and other end are the same.

findAllEdgePorts

public static java.util.Collection findAllEdgePorts(PortModel seed,
                                                    int seedEnd,
                                                    int otherEnd,
                                                    java.util.Collection retVal)
Returns the port models connected to a seed port, and its subports, through edges with the specified edge end types.

Parameters:
seed - The seed port. Never null.
seedEnd - Edge port index associated with the seed end type (such as EdgeModel.INDEX_???_END). >=0.
otherEnd - Edge port index associated with the other end type (such as EdgeModel.INDEX_???_END). >=0.
retVal - Return value object. The connected port models (PortModel), possibly including seed. If not a set, may contain duplicates. Reflects the relative order of the edges. Never null.
Returns:
Reference to retVal. Never null.
Throws:
java.lang.IllegalArgumentException - Seed and other end are the same.

hasEdgeVertices

public static boolean hasEdgeVertices(VertexModel seed,
                                      int seedEnd,
                                      int otherEnd)
Returns true if any vertex models are connected to a seed vertex through edges with the specified edge end types.

Parameters:
seedEnd - Edge port index associated with the seed end type (such as EdgeModel.INDEX_???_END). >=0.
otherEnd - Edge port index associated with the other end type (such as EdgeModel.INDEX_???_END). >=0.
Returns:
The result.

isSource

public static boolean isSource(VertexModel vert)
Returns true if a vertex is a source node (no incoming edges). Specifically, a source node is one with no edges having the vertex as its head end (EdgeModel.INDEX_HEAD_END).

Parameters:
vert - The vertex. Never null.
Returns:
The result.

isSink

public static boolean isSink(VertexModel vert)
Returns true if a vertex is a sink node (no outgoing edges). Specifically, a sink node is one with no edges having the vertex as its tail end (EdgeModel.INDEX_TAIL_END).

Parameters:
vert - The vertex. Never null.
Returns:
The result.

findSources

public static java.util.Collection findSources(java.util.Collection parts,
                                               java.util.Collection retVal)
Finds the source vertex models in a group of part models.

Parameters:
retVal - Return value object. The source models (VertexModel). Reflects the relative order of the models in parts. Never null. Can be verts.
Returns:
Reference to retVal. Never null.

findSinks

public static java.util.Collection findSinks(java.util.Collection parts,
                                             java.util.Collection retVal)
Finds the sink vertex models in a group of part models.

Parameters:
retVal - Return value object. The sink models (VertexModel). Reflects the relative order of the models in parts. Never null. Can be verts.
Returns:
Reference to retVal. Never null.

traceGraph

public static java.util.List traceGraph(VertexModel seedNode,
                                        VertexModel pruneNode,
                                        boolean traceForward,
                                        boolean traceBackward,
                                        java.util.List retVal)
Performs a breadth-first search of a graph starting with a seed node and returning the graph nodes found. Preserves the relative distance from the seed and blocks cycles. Includes provisions for pruning a subgraph (such as the "far" subgraph of a cyclic graph), and for tracing forward and backward edges.

Parameters:
seedNode - The seed graph node of the trace. The seed is included in the trace unless pruned. If null, the trace will be empty.
pruneNode - A graph node whose subgraph will be pruned from the trace. The prune node is excluded from the trace. Null if none (prune nothing from the trace). If the seed, the trace is generated and then the seed is removed.
traceForward - If true, forward connections (tail to head) are traced.
traceBackward - If true, backward connections (head to tail) are traced.
retVal - Return value object. The trace, as a list of vertex models (VertexModel). Never null. Empty if seed is null. The seed will be the first entry if not pruned. Any previous entries will be lost.
Returns:
Reference to retVal.
Throws:
java.lang.IllegalArgumentException - The return value object is null.

traceList

public static java.util.List traceList(VertexModel seedNode,
                                       VertexModel pruneNode,
                                       boolean traceForward,
                                       java.util.List retVal)
Performs a search of a graph starting with a seed node and returning a list of nodes found. The list is formed by following the first edge of each node, while blocking cycles. Includes provisions for pruning a subgraph (such as the "far" subgraph of a cyclic graph), and for tracing forward or backward edges.

Parameters:
seedNode - The seed graph node of the trace. The seed is included in the trace unless pruned. If null, the trace will be empty.
pruneNode - A graph node whose subgraph will be pruned from the trace. The prune node is excluded from the trace. Null if none (prune nothing from the trace). If the seed, the trace is generated and then the seed is removed.
traceForward - If true, forward connections (tail to head) are traced; otherwise, backward connections (head to tail) are traced.
retVal - Return value object. The trace, as a list of vertex models (VertexModel). Never null. Empty if seed is null. The seed will be the first entry if not pruned. Any previous entries will be lost.
Returns:
Reference to retVal.
Throws:
java.lang.IllegalArgumentException - The return value object is null.