Class Edge
- All Implemented Interfaces:
Serializable
,Comparable<Edge>
An edge carries information about the nodes it connects, its type, whether it is part of a ring (for example, an aromatic ring in a molecule), and whether it is a bridge in graph it is part of. In addition, for ring edges a bit flag array makes it possible to easily follow a ring in a molecule.
Note that only 30 bits are actually available for the type of the edge. The two most significant bits are reserved as flags, for example, for marking ring bonds.
- Since:
- 2002.03.11
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
the mask to extract the bridge flagprotected Node
the destination node of the edgestatic final int
the mask for the edge flags (wildcard and ring)protected long
the flags for rings and bridgesprotected int
a marker for internal use (e.g.static final int
the flag for the edge type to distinguish ring edgesstatic final long
the mask to extract the ring flagsprotected Node
the source node of the edgeprotected int
the type of the edge, e.g.static final int
the mask for the base typestatic final int
the flag for a wildcard type -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear the ring flags of the edge.int
Compare two edges (w.r.t.boolean
Check whether two edges are equal.int
Get the base type (attribute/label) of an edge.getDest()
Get the destination node of the edge.long
getRings()
Get the ring flags of the edge.Get the source node of the edge.int
getType()
Get the full type (attribute/label) of an edge.int
hashCode()
Compute the Hash code of an edge.boolean
isBridge()
Check whether the edge is a bridge.boolean
isInRing()
Check whether the edge is part of a ring.boolean
Check whether this is a special edge (wildcard or ring).boolean
Check whether this is a wildcard edge.void
markBridge
(boolean bridge) Set or clear the bridge flag of the edge.void
markRing
(boolean ring) Set or clear the ring type flag of the edge.void
maskType
(int mask) Mask the edge type with the given mask.
-
Field Details
-
TYPEMASK
public static final int TYPEMASKthe mask for the base type- See Also:
-
FLAGMASK
public static final int FLAGMASKthe mask for the edge flags (wildcard and ring)- See Also:
-
WILDCARD
public static final int WILDCARDthe flag for a wildcard type- See Also:
-
RING
public static final int RINGthe flag for the edge type to distinguish ring edges- See Also:
-
BRIDGE
public static final long BRIDGEthe mask to extract the bridge flag- See Also:
-
RINGMASK
public static final long RINGMASKthe mask to extract the ring flags- See Also:
-
type
protected int typethe type of the edge, e.g.SINGLE
-
mark
protected int marka marker for internal use (e.g. for a substructure) -
src
the source node of the edge -
dst
the destination node of the edge -
flags
protected long flagsthe flags for rings and bridges
-
-
Constructor Details
-
Edge
Create an edge of a given type between two nodes.The created edge is automatically added to the two nodes it connects.
- Parameters:
src
- the source node of the edgedst
- the destination node of the edgetype
- the type of the edgeflags
- the ring and bridge flags of the edge- Since:
- 2009.05.04 (Christian Borgelt)
-
Edge
Create an edge of a given type between two nodes.The created edge is automatically added to the two nodes it connects.
- Parameters:
src
- the source node of the edgedst
- the destination node of the edgetype
- the type of the edge- Since:
- 2002.03.11 (Christian Borgelt)
-
-
Method Details
-
getType
public int getType()Get the full type (attribute/label) of an edge.- Returns:
- the type of the edge
- Since:
- 2002.03.11 (Christian Borgelt)
-
getBaseType
public int getBaseType()Get the base type (attribute/label) of an edge.- Returns:
- the type of the edge
- Since:
- 2009.08.13 (Christian Borgelt)
-
maskType
public void maskType(int mask) Mask the edge type with the given mask.- Parameters:
mask
- the mask for the edge typ- Since:
- 2002.03.11 (Christian Borgelt)
-
isSpecial
public boolean isSpecial()Check whether this is a special edge (wildcard or ring).- Returns:
- whether this is a special edge
- Since:
- 2008.08.13 (Christian Borgelt)
-
isWildcard
public boolean isWildcard()Check whether this is a wildcard edge.- Returns:
- whether this is a wildcard edge
- Since:
- 2008.08.13 (Christian Borgelt)
-
isInRing
public boolean isInRing()Check whether the edge is part of a ring.This function only extracts the ring flag from the edge type. It does not analyze the graph containing the edge.
- Returns:
- whether the edge is part of a ring
- Since:
- 2002.03.11 (Christian Borgelt)
-
markRing
public void markRing(boolean ring) Set or clear the ring type flag of the edge.- Parameters:
ring
- whether the edge is in a ring- Since:
- 2007.06.30 (Christian Borgelt)
-
getSource
Get the source node of the edge.- Returns:
- the source node of the edge
- Since:
- 2002.03.11 (Christian Borgelt)
-
getDest
Get the destination node of the edge.- Returns:
- the destination node of the edge
- Since:
- 2002.03.11 (Christian Borgelt)
-
getRings
public long getRings()Get the ring flags of the edge.This function only extracts the ring flags from the flags field. It does not analyze the graph containing the edge.
- Returns:
- the ring flags of the edge
- Since:
- 2002.03.11 (Christian Borgelt)
-
clearRings
public void clearRings()Clear the ring flags of the edge.- Since:
- 2007.06.30 (Christian Borgelt)
-
isBridge
public boolean isBridge()Check whether the edge is a bridge.This function only extracts the bridge flag from the flags field. It does not analyze the graph containing the edge.
- Returns:
- whether the edge is a bridge
- Since:
- 2002.03.11 (Christian Borgelt)
-
markBridge
public void markBridge(boolean bridge) Set or clear the bridge flag of the edge.- Parameters:
bridge
- whether the edge is a bridge- Since:
- 2002.03.11 (Christian Borgelt)
-
compareTo
Compare two edges (w.r.t. their marker values).This function is needed in
NamedGraph.split()
(indirectly throughArrays.sort()
).- Specified by:
compareTo
in interfaceComparable<Edge>
- Parameters:
obj
- the edge to compare to- Returns:
- the sign of the difference of the edge markers, that is,
-1
,0
, or+1
as the marker of this edge is less than, equal to, or greater than the marker of the edge given as an argument - Since:
- 2007.06.14 (Christian Borgelt)
-
hashCode
public int hashCode()Compute the Hash code of an edge. -
equals
Check whether two edges are equal.This method checks whether the two edges connect nodes of the same type with an edge of the same type. If this is the case, the function returns
true
, otherwise it returnsfalse
.
-