Class Node
java.lang.Object
jdg.graph.Node
A class for representing a node of a graph (implemented using adjacency lists)
- Author:
- Luca Castelli Aleardi (Ecole Polytechnique, feb 2021)
-
Field Summary
FieldsModifier and TypeFieldDescriptionintindex of a node: an integer value from 0..n-1label of the node: vertex label can differ from vertex indexlist of neighbors of the current nodeinttag of node: useful for "marking" a nodedoubleweight of the node: useful for some applications -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNeighbor(Node v) booleanintdegree()getLabel()intgetTag()inthashCode()booleanCheck whether the current node is isolated (no neighbors)Return the list of neighboring nodesvoidvoidsetColor(int r, int g, int b) voidvoidsetTag(int tag) toString()
-
Field Details
-
neighbors
-
label
label of the node: vertex label can differ from vertex index -
tag
public int tagtag of node: useful for "marking" a node -
weight
public double weightweight of the node: useful for some applications -
index
public int indexindex of a node: an integer value from 0..n-1 -
color
-
-
Constructor Details
-
Node
public Node(int index) -
Node
-
Node
-
-
Method Details
-
addNeighbor
-
removeNeighbor
-
adjacent
-
isIsolated
public boolean isIsolated()Check whether the current node is isolated (no neighbors)- Returns:
- true if the current node is isolated (no neighbors)
-
setColor
public void setColor(int r, int g, int b) -
neighborsList
-
setTag
public void setTag(int tag) -
getTag
public int getTag() -
setLabel
-
getLabel
-
degree
public int degree() -
toString
-
hashCode
-