Packagecom.yworks.yfiles.base
Classpublic class Edge
InheritanceEdge Inheritance com.yworks.yfiles.base.GraphObject

Represents an edge, i.e., a directed connection between two nodes (represented by instances of class com.yworks.yfiles.base.Node) in the directed graph data type com.yworks.yfiles.base.Graph. The directed stems from the fact that an edge has a distinct source node and a distinct target node. Using pair notation, an edge would be written as (<source node>, <target node>).

Most notably, an edge provides access to its source node ( source()) and its target node ( target()). Note that an edge can have the same node as its source and target. Such an edge is then called "self-loop" and method selfLoop yields true.

Important: Class Graph is the single authority for any structural changes to the graph data type. Specifically, this means that there is no way to create or delete a node or an edge without using an actual Graph instance.

See also

com.yworks.yfiles.base.Node
com.yworks.yfiles.base.Graph
source()
target()
selfLoop


Public Properties
 PropertyDefined By
  graph : Graph
[read-only] Returns the graph this edge belongs to.
Edge
  selfLoop : Boolean
[read-only] Returns true if and only if this edge is a self-loop.
Edge
Public Methods
 MethodDefined By
  
Edge(g:Graph, v:Node, e1:Edge, w:Node, e2:Edge, d1:int, d2:int, init:Boolean = true)
Creates a new edge that belongs to the given graph.
Edge
  
Creates a copy of this edge that will be inserted into the given graph connecting the given source and target nodes.
Edge
  
getClass():Class
[override]
Edge
  
index():int
Returns the index of this edge within its graph G.
Edge
  
Returns the successor of this edge in the list of incoming edges at its target node.
Edge
  
Returns the successor of this edge in the list of outgoing edges at its source node.
Edge
  
Returns the node at the opposite edge end with respect to the given node.
Edge
  
Returns the predecessor of this edge in the list of incoming edges at its target node.
Edge
  
Returns the predecessor of this edge in the list of outgoing edges at its source node.
Edge
  
Returns the source node connected to this edge.
Edge
  
Returns the target node connected to this edge.
Edge
  
toString():String
Returns a String representation of this edge.
Edge
Protected Methods
 MethodDefined By
  
initEdge(g:Graph, v:Node, e1:Edge, w:Node, e2:Edge, d1:int, d2:int):void
Initializes this object.
Edge
  
newEdge(g:Graph, v:Node, e1:Edge, w:Node, e2:Edge, d1:int, d2:int):Edge
[static] Creates a new edge that belongs to the given graph.
Edge
  
onReinsert():void
Callback method that is invoked from a graph just before this edge will be reinserted into that graph.
Edge
Property Detail
graphproperty
graph:Graph  [read-only]

Returns the graph this edge belongs to. If the edge does not belong to a graph, because it was removed or hidden from it, this method returns null.


Implementation
    public function get graph():Graph
selfLoopproperty 
selfLoop:Boolean  [read-only]

Returns true if and only if this edge is a self-loop. An edge is called a self-loop, if it is adjacent to only one node, i.e., source node and target node are the same.


Implementation
    public function get selfLoop():Boolean
Constructor Detail
Edge()Constructor
public function Edge(g:Graph, v:Node, e1:Edge, w:Node, e2:Edge, d1:int, d2:int, init:Boolean = true)

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

and an iteration over the edges at w returns e

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

Parameters
g:Graph
 
v:Node — The source node of the edge.
 
e1:Edge — An edge with source node v.
 
w:Node — The target node of the edge.
 
e2:Edge — An edge with target node w.
 
d1:int — One of the object insertion specifiers com.yworks.yfiles.base.Graph.BEFORE or com.yworks.yfiles.base.Graph.AFTER .
 
d2:int — One of the object insertion specifiers com.yworks.yfiles.base.Graph.BEFORE or com.yworks.yfiles.base.Graph.AFTER .
 
init:Boolean (default = true) — An internally used switch to help handle proper instance initialization in inheritance chains where classes can have multiple constructor-like factory methods. This parameter can safely be ignored/omitted when calling the constructor.

See also

Method Detail
createCopy()method
public function createCopy(g:Graph, v:Node, w:Node):Edge

Creates a copy of this edge that will be inserted into the given graph connecting the given source and target nodes.

Parameters

g:Graph — The graph the created edge will belong to.
 
v:Node — The source node of the created edge.
 
w:Node — The target node of the created edge.

Returns
Edge — The newly created Edge object.
getClass()method 
override public function getClass():Class

Returns
Class
index()method 
public function index():int

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().

Note that indices are subject to change whenever the sequence of edges in a graph is modified by either removing, hiding, reinserting, or unhiding an edge, or by explicitly changing its position in the sequence.

Precondition This edge must belong to some graph.

Returns
int

See also

initEdge()method 
protected final function initEdge(g:Graph, v:Node, e1:Edge, w:Node, e2:Edge, d1:int, d2:int):void

Initializes this object. See the documentation of the corresponding factory method newEdge() for details.

Parameters

g:Graph
 
v:Node
 
e1:Edge
 
w:Node
 
e2:Edge
 
d1:int
 
d2:int

See also

newEdge()method 
protected static function newEdge(g:Graph, v:Node, e1:Edge, w:Node, e2:Edge, d1:int, d2:int):Edge

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

and an iteration over the edges at w returns e

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

Parameters

g:Graph
 
v:Node — The source node of the edge.
 
e1:Edge — An edge with source node v.
 
w:Node — The target node of the edge.
 
e2:Edge — An edge with target node w.
 
d1:int — One of the object insertion specifiers com.yworks.yfiles.base.Graph.BEFORE or com.yworks.yfiles.base.Graph.AFTER .
 
d2:int — One of the object insertion specifiers com.yworks.yfiles.base.Graph.BEFORE or com.yworks.yfiles.base.Graph.AFTER .

Returns
Edge

See also

nextInEdge()method 
public function nextInEdge():Edge

Returns the successor of this edge in the list of incoming edges at its target node. If this edge is the last incoming edge at its target node, then null is returned.

Precondition This edge must belong to some graph.

Returns
Edge

See also

nextOutEdge()method 
public function nextOutEdge():Edge

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 is returned.

Precondition This edge must belong to some graph.

Returns
Edge

See also

onReinsert()method 
protected function onReinsert():void

Callback method that is invoked from a graph just before this edge will be reinserted into that graph.

opposite()method 
public function opposite(v:Node):Node

Returns the node at the opposite edge end with respect to the given node.

Note that self-loops have the same node at both edge ends.

Precondition The given node must be either the edge's source node or target node.

Parameters

v:Node

Returns
Node
prevInEdge()method 
public function prevInEdge():Edge

Returns the predecessor of this edge in the list of incoming edges at its target node. If this edge is the first incoming edge at its target node, then null is returned.

Precondition This edge must belong to some graph.

Returns
Edge

See also

prevOutEdge()method 
public function prevOutEdge():Edge

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 is returned.

Precondition This edge must belong to some graph.

Returns
Edge

See also

source()method 
public function source():Node

Returns the source node connected to this edge.

Returns
Node

See also

target()method 
public function target():Node

Returns the target node connected to this edge.

Returns
Node

See also

toString()method 
public function toString():String

Returns a String representation of this edge.

Returns
String