Package org.graph4j
Class Edge<E>
java.lang.Object
org.graph4j.Edge<E>
- Type Parameters:
E- the type of edge labels in this graph.
- All Implemented Interfaces:
Comparable<Edge>
An edge is a pair of vertices. It may or may not be part of the graph. Edges
are not stored as objects in the graph structure, instead they are created on
demand.
- Author:
- Cristian Frăsinaru
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
directed
protected boolean directed -
source
protected int source -
target
protected int target -
data
-
label
-
-
Constructor Details
-
Edge
public Edge(int source, int target) - Parameters:
source- the source endpoint of the edge.target- the target endpoint of the edge.
-
Edge
public Edge(int source, int target, boolean directed) - Parameters:
source- the source endpoint of the edge.target- the target endpoint of the edge.directed-trueif the edge has a direction (in case of digraphs).
-
Edge
public Edge(int source, int target, double weight) - Parameters:
source- the source endpoint of the edge.target- the target endpoint of the edge.weight- the weight of the edge.
-
Edge
- Parameters:
source- the source endpoint of the edge.target- the target endpoint of the edge.label- the label of the edge.
-
Edge
- Parameters:
source- the source endpoint of the edge.target- the target endpoint of the edge.label- the label of the edge.weight- the weight of the edge.
-
Edge
- Parameters:
source- the source endpoint of the edge.target- target the target endpoint of the edge.label- the label of the edge.data- the data associated with the edge.
-
-
Method Details
-
source
public int source()- Returns:
- the source endpoint of the edge.
-
target
public int target()- Returns:
- the target (sink) endpoint of the edge.
-
isDirected
public boolean isDirected()- Returns:
trueif the edge is directed (is case of digraphs).
-
isSelfLoop
public boolean isSelfLoop()- Returns:
trueif the source and the target are the same.
-
weight
public double weight()- Returns:
- the weight associated with the edge, or
1in the case of unweighted graphs.
-
data
-
dataOrDefault
public double dataOrDefault(int dataType, int defaultValue) -
label
- Returns:
- the label associated with the edge, or
nullin the case of unlabeled graphs.
-
flip
Flips source and target, for directed edges.- Returns:
- a new edge with the direction reversed.
-
isAdjacentTo
- Parameters:
other- another edge.- Returns:
trueif this edge has a common endpoint with the other.
-
toString
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<E>
-