y.base
Class Edge

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

public class Edge
extends y.base.GraphObject

Represents a directed connection between two nodes in a graph.


Constructor Summary
protected Edge(Graph g, Node v, Edge e1, Node w, Edge e2, int d1, int d2)
          Creates a new edge that belongs to the given graph.
 
Method Summary
 Edge createCopy(Graph g, Node v, Node w)
          Creates a copy of this edge that will be inserted in the given graph connecting the given source and target nodes.
 Graph getGraph()
          Returns the graph this edge belongs to.
 int index()
          Returns the index of this edge within its graph G .
 boolean isSelfLoop()
          Returns true if and only if this edge is a selfloop.
 Edge nextInEdge()
          Returns the successor of this edge in the list of ingoing edges at its target node.
 Edge nextOutEdge()
          Returns the successor of this edge in the list of outgoing edges at its source node.
protected  void onReinsert()
          Callback method that is invoked from a graph just before this edge will be reinserted into that graph.
 Node opposite(Node v)
          Returns the node at this edge with is on the opposite side of the given node.
 Edge prevInEdge()
          Returns the predecessor of this edge in the list of ingoing edges at its target node.
 Edge prevOutEdge()
          Returns the predecessor of this edge in the list of outgoing edges at its source node.
 Node source()
          Returns the source node connected to this edge.
 Node target()
          Returns the target node connected to this edge.
 String toString()
          Returns a string representation of this edge.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Edge

protected Edge(Graph g,
               Node v,
               Edge e1,
               Node w,
               Edge e2,
               int d1,
               int d2)
Creates a new edge that belongs to the given graph. The new edge e has source node v and target node w. Edge e is inserted in such a way that an iteration over the edges at node v returns e after (before) e1 if d1 == AFTER (d1 == BEFORE) and an iteration over the edges at w return e after (before) e2 if d2 == AFTER (d2 == BEFORE).

Precondition: Edge e1 must have source node v and edge e2 must have target node w

Parameters:
v - the source node of the edge
e1 - an edge with source node v
w - the target node of the edge
e2 - an edge with target node w
d1 - one of the object insertion specifiers BEFORE or AFTER
d2 - one of the object insertion specifiers BEFORE or AFTER
Method Detail

createCopy

public Edge createCopy(Graph g,
                       Node v,
                       Node w)
Creates a copy of this edge that will be inserted in the given graph connecting the given source and target nodes.

Parameters:
g - the graph the created edge will belong to.
v - the source node of the created edge
w - the target node of the created edge
Returns:
a newly created edge.

getGraph

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


index

public int index()
Returns the index of this edge within its graph G . Edge indices represent the ordering of standard edge iteration on G. The value of an index is >= 0 and < G.edgeCount().

Precondition: This edge must belong to some graph


source

public Node source()
Returns the source node connected to this edge.


target

public Node target()
Returns the target node connected to this edge.


opposite

public Node opposite(Node v)
Returns the node at this edge with is on the opposite side of the given node.

Precondition: the given node must be either source() or target().


isSelfLoop

public boolean isSelfLoop()
Returns true if and only if this edge is a selfloop. An edge is called a selfloop if it is adjacent to only one node, i.e. source() == target().


toString

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

Overrides:
toString in class Object

onReinsert

protected void onReinsert()
Callback method that is invoked from a graph just before this edge will be reinserted into that graph.


nextOutEdge

public Edge nextOutEdge()
Returns the successor of this edge in the list of outgoing edges at its source node. If this edge is the last outgoing edge at its source node, then null will be returned.

Precondition: e is contained in some graph.


nextInEdge

public Edge nextInEdge()
Returns the successor of this edge in the list of ingoing edges at its target node. If this edge is the last ingoing edge at its target node, then null will be returned.

Precondition: e is contained in some graph.


prevOutEdge

public Edge prevOutEdge()
Returns the predecessor of this edge in the list of outgoing edges at its source node. If this edge is the first outgoing edge at its source node, then null will be returned.

Precondition: e is contained in some graph.


prevInEdge

public Edge prevInEdge()
Returns the predecessor of this edge in the list of ingoing edges at its target node. If this edge is the first ingoing edge at its target node, then null will be returned.

Precondition: e is contained in some graph.


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

2003