net.xqhs.graphs.representation.linear
Class PathElement

java.lang.Object
  extended by net.xqhs.graphs.representation.linear.PathElement

public class PathElement
extends java.lang.Object

Class for the element of a path in a graph linearization (see LinearGraphRepresentation).

Each path element is associated with a node in the graph (seen as a Node implementation).

An instance contains information about the node, the distance from the start of the path, the previous node in the path (its parent), and its children: "own children" are the children of the node, according to the tree represented by the path. The "other children" are nodes connected with the current one (there exist edges from the node to the children), but have been marked by the algorithm as "own children" of another path element.

Author:
Andrei Olaru

Field Summary
(package private)  java.util.List<PathElement> children
          The (ordered) list of children ("own children") of the current element in the path.
(package private)  int depth
          The distance from the root of the path.
(package private)  int forwardLength
          The distance, in the path, from the current element to the farthest leaf in the path.
(package private)  Node node
          The node to which this instance is associated.
(package private)  java.util.List<PathElement> otherChildren
          The (ordered) list of nodes / elements that are connected to the node, but are not children of it in the current path ("other children").
(package private)  PathElement parent
          The parent of the element, in the current path.
 
Constructor Summary
PathElement(Node node, int distance, PathElement parent)
          Creates a new instance, associated with a Node instance.
 
Method Summary
 java.util.List<PathElement> getChildren()
           
 Node getNode()
           
 java.util.List<PathElement> getOtherChildren()
           
 boolean pathContains(PathElement el1)
          Checks if the path from root to the current node already contains a specified element.
 java.lang.String toString()
          Returns a compact string representation of the path element:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

node

Node node
The node to which this instance is associated.


depth

int depth
The distance from the root of the path. It is 0-based, with 0 for the root.


forwardLength

int forwardLength
The distance, in the path, from the current element to the farthest leaf in the path.


parent

PathElement parent
The parent of the element, in the current path.


children

java.util.List<PathElement> children
The (ordered) list of children ("own children") of the current element in the path.


otherChildren

java.util.List<PathElement> otherChildren
The (ordered) list of nodes / elements that are connected to the node, but are not children of it in the current path ("other children").

Constructor Detail

PathElement

public PathElement(Node node,
                   int distance,
                   PathElement parent)
Creates a new instance, associated with a Node instance. The constructor requires the parent and the distance from root.

Parameters:
node - : the associated node.
distance - : the distance from root (depth of the node). 0 is for root.
parent - : the parent element, in the current path.
Method Detail

pathContains

public boolean pathContains(PathElement el1)
Checks if the path from root to the current node already contains a specified element.

Parameters:
el1 - : the element to check for.
Returns:
true if the element is contained on the path, false otherwise.

toString

public java.lang.String toString()
Returns a compact string representation of the path element:

node label (depth : parent / n-children : n-otherChildren / forwardLength

Overrides:
toString in class java.lang.Object

getNode

public Node getNode()
Returns:
the node associated with this element.

getChildren

public java.util.List<PathElement> getChildren()
Returns:
the children of this element ("own children").

getOtherChildren

public java.util.List<PathElement> getOtherChildren()
Returns:
the "other children" of this element.