22
33# Represents an object with a name, node type, and position that can serve as a
44# node in a graph.
5+ from typing import Optional
56from causallearn .graph .NodeType import NodeType
67from causallearn .graph .NodeVariableType import NodeVariableType
78
89
910class Node :
11+ node_type : NodeType
12+ node_name : str
1013
14+ def __init__ (self , node_name : Optional [str ] = None , node_type : Optional [NodeType ] = None ) -> None :
15+ self .node_name = node_name
16+ self .node_type = node_type
17+
1118 # @return the name of the variable.
1219 def get_name (self ) -> str :
13- pass
20+ return self . node_name
1421
1522 # set the name of the variable
1623 def set_name (self , name : str ):
17- pass
24+ self . node_name = name
1825
1926 # @return the node type of the variable
2027 def get_node_type (self ) -> NodeType :
21- pass
28+ return self . node_type
2229
2330 # set the node type of the variable
2431 def set_node_type (self , node_type : NodeType ):
25- pass
32+ self . node_type = node_type
2633
2734 # @return the intervention type
2835 def get_node_variable_type (self ) -> NodeVariableType :
@@ -35,7 +42,7 @@ def set_node_variable_type(self, var_type: NodeVariableType):
3542
3643 # @return the name of the node as its string representation
3744 def __str__ (self ):
38- pass
45+ return self . node_name
3946
4047 # @return the x coordinate of the center of the node
4148 def get_center_x (self ) -> int :
@@ -59,7 +66,7 @@ def set_center(self, center_x: int, center_y: int):
5966
6067 # @return a hashcode for this variable
6168 def __hash__ (self ):
62- pass
69+ return hash ( self . node_name )
6370
6471 # @return true iff this variable is equal to the given variable
6572 def __eq__ (self , other ):
0 commit comments