public class Edge extends java.lang.Object implements java.lang.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.
Modifier and Type | Field and Description |
---|---|
static long |
BRIDGE
the mask to extract the bridge flag
|
protected Node |
dst
the destination node of the edge
|
static int |
FLAGMASK
the mask for the edge flags (wildcard and ring)
|
protected long |
flags
the flags for rings and bridges
|
protected int |
mark
a marker for internal use (e.g.
|
static int |
RING
the flag for the edge type to distinguish ring edges
|
static long |
RINGMASK
the mask to extract the ring flags
|
protected Node |
src
the source node of the edge
|
protected int |
type
the type of the edge, e.g.
|
static int |
TYPEMASK
the mask for the base type
|
static int |
WILDCARD
the flag for a wildcard type
|
Modifier | Constructor and Description |
---|---|
protected |
Edge(Node src,
Node dst,
int type)
Create an edge of a given type between two nodes.
|
protected |
Edge(Node src,
Node dst,
int type,
long flags)
Create an edge of a given type between two nodes.
|
Modifier and Type | Method and Description |
---|---|
void |
clearRings()
Clear the ring flags of the edge.
|
int |
compareTo(Edge obj)
Compare two edges (w.r.t.
|
boolean |
equals(java.lang.Object edge)
Check whether two edges are equal.
|
int |
getBaseType()
Get the base type (attribute/label) of an edge.
|
Node |
getDest()
Get the destination node of the edge.
|
long |
getRings()
Get the ring flags of the edge.
|
Node |
getSource()
Get the source node of the edge.
|
int |
getType()
Get the full type (attribute/label) of an edge.
|
boolean |
isBridge()
Check whether the edge is a bridge.
|
boolean |
isInRing()
Check whether the edge is part of a ring.
|
boolean |
isSpecial()
Check whether this is a special edge (wildcard or ring).
|
boolean |
isWildcard()
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.
|
public static final int TYPEMASK
public static final int FLAGMASK
public static final int WILDCARD
public static final int RING
public static final long BRIDGE
public static final long RINGMASK
protected int type
SINGLE
protected int mark
protected Node src
protected Node dst
protected long flags
protected Edge(Node src, Node dst, int type)
The created edge is automatically added to the two nodes it connects.
src
- the source node of the edgedst
- the destination node of the edgetype
- the type of the edgeprotected Edge(Node src, Node dst, int type, long flags)
The created edge is automatically added to the two nodes it connects.
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 edgepublic int getType()
public int getBaseType()
public void maskType(int mask)
mask
- the mask for the edge typpublic boolean isSpecial()
public boolean isWildcard()
public boolean isInRing()
This function only extracts the ring flag from the edge type. It does not analyze the graph containing the edge.
public void markRing(boolean ring)
ring
- whether the edge is in a ringpublic Node getSource()
public Node getDest()
public long getRings()
This function only extracts the ring flags from the flags field. It does not analyze the graph containing the edge.
public void clearRings()
public boolean isBridge()
This function only extracts the bridge flag from the flags field. It does not analyze the graph containing the edge.
public void markBridge(boolean bridge)
bridge
- whether the edge is a bridgepublic int compareTo(Edge obj)
This function is needed in NamedGraph.split()
(indirectly through Arrays.sort()).
compareTo
in interface java.lang.Comparable<Edge>
obj
- the edge to compare to-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 argumentpublic boolean equals(java.lang.Object edge)
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 returns
false
.
equals
in class java.lang.Object
edge
- the edge to compare to