y.base
Class Node

java.lang.Object
  |
  +--y.base.GraphObject
        |
        +--y.base.Node

public class Node
extends y.base.GraphObject

Represents a vertex in the directed graph datatype Graph.


Constructor Summary
protected Node(Graph g)
          Instantiates a new Node object that will be part of the given graph.
 
Method Summary
 Node createCopy(Graph g)
          Creates a copy of this node that will be inserted in the given graph.
 int degree()
          Returns the number of ingoing and outgoing edges at this node.
 EdgeCursor edges()
          Returns an edge cursor for all in- and outgoing edges at this node.
 Edge firstInEdge()
          Returns the first ingoing edge at this node, or null if it does not exist.
 Edge firstOutEdge()
          Returns the first outgoing edge at this node, or null if it does not exist.
 Edge getEdge(Node opposite)
          Returns an edge that connects this node with the given node, if such an edge exists.
 Edge getEdgeFrom(Node source)
          Returns an edge (source,v), if such an edge exists.
 Edge getEdgeTo(Node target)
          Returns an edge (v,target), if such an edge exists.
 Graph getGraph()
          Returns the graph this node belongs to.
 int inDegree()
          Returns the number of ingoing edges at this node.
 int index()
          Returns this node's index within its graph G .
 EdgeCursor inEdges()
          Returns an edge cursor for all ingoing edges at this node.
 EdgeCursor inEdges(Edge startEdge)
          Returns an edge cursor for ingoing edges at this node that starts that the given edge.
 Edge lastInEdge()
          Returns the last ingoing edge at this node, or null if it does not exist.
 Edge lastOutEdge()
          Returns the last outgoing edge at this node, or null if it does not exist.
 NodeCursor neighbors()
          Returns a node cursor for all neighbor nodes of this node.
 int outDegree()
          Returns the number of outgoing edges at this node.
 EdgeCursor outEdges()
          Returns an edge cursor for all outgoing edges at this node.
 EdgeCursor outEdges(Edge startEdge)
          Returns an edge cursor for outgoing edges at this node that starts that the given edge.
 NodeCursor predecessors()
          Returns a node cursor for all predecessor nodes of this node.
 void sortInEdges(Comparator c)
          Sorts ingoing edges at this node according to c.
 void sortOutEdges(Comparator c)
          Sorts outgoing edges at this node according to c.
 NodeCursor successors()
          Returns a node cursor for all successor nodes of this node.
 String toString()
          Returns a string representation of this node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Node

protected Node(Graph g)
Instantiates a new Node object that will be part of the given graph.

Parameters:
g - the graph the created node will belong to.
Method Detail

createCopy

public Node createCopy(Graph g)
Creates a copy of this node that will be inserted in the given graph.

Parameters:
g - the graph the created node will belong to.
Returns:
a newly created node

degree

public int degree()
Returns the number of ingoing and outgoing edges at this node.


inDegree

public int inDegree()
Returns the number of ingoing edges at this node.


outDegree

public int outDegree()
Returns the number of outgoing edges at this node.


index

public int index()
Returns this node's index within its graph G . Node indices represent the ordering of standard node iteration on G. The value of an index is >= 0 and < G.nodeCount().

Precondition: This edge must belong to some graph


getGraph

public Graph getGraph()
Returns the graph this node belongs to. If the node does not belong to a graph because it was removed from it, this method will return null.


firstOutEdge

public Edge firstOutEdge()
Returns the first outgoing edge at this node, or null if it does not exist.


firstInEdge

public Edge firstInEdge()
Returns the first ingoing edge at this node, or null if it does not exist.


lastOutEdge

public Edge lastOutEdge()
Returns the last outgoing edge at this node, or null if it does not exist.


lastInEdge

public Edge lastInEdge()
Returns the last ingoing edge at this node, or null if it does not exist.


edges

public EdgeCursor edges()
Returns an edge cursor for all in- and outgoing edges at this node.


inEdges

public EdgeCursor inEdges()
Returns an edge cursor for all ingoing edges at this node.


inEdges

public EdgeCursor inEdges(Edge startEdge)
Returns an edge cursor for ingoing edges at this node that starts that the given edge. The cyclic sequence order is the same as returned by Node.inEdges().

Precondition: startEdge is an ingoing edge at this node

Parameters:
startEdge - the first edge being accessed by the returned cursor.

outEdges

public EdgeCursor outEdges()
Returns an edge cursor for all outgoing edges at this node.


outEdges

public EdgeCursor outEdges(Edge startEdge)
Returns an edge cursor for outgoing edges at this node that starts that the given edge. The cyclic sequence order is the same as returned by Node.outEdges().

Precondition: startEdge is an outgoing edge at this node

Parameters:
startEdge - the first edge being accessed by the returned cursor.

neighbors

public NodeCursor neighbors()
Returns a node cursor for all neighbor nodes of this node.


predecessors

public NodeCursor predecessors()
Returns a node cursor for all predecessor nodes of this node.


successors

public NodeCursor successors()
Returns a node cursor for all successor nodes of this node.


getEdgeTo

public Edge getEdgeTo(Node target)
Returns an edge (v,target), if such an edge exists. Otherwise null is returned.


getEdgeFrom

public Edge getEdgeFrom(Node source)
Returns an edge (source,v), if such an edge exists. Otherwise null is returned.


getEdge

public Edge getEdge(Node opposite)
Returns an edge that connects this node with the given node, if such an edge exists. Otherwise null is returned.


sortInEdges

public void sortInEdges(Comparator c)
Sorts ingoing edges at this node according to c.


sortOutEdges

public void sortOutEdges(Comparator c)
Sorts outgoing edges at this node according to c.


toString

public String toString()
Returns a string representation of this node.

Overrides:
toString in class Object

© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003