1- from typing import List , Optional
2-
31from .log import LogTracer , Tracer
4- from algorithm_visualizer .types import Number , Serializable , UNDEFINED
2+ from algorithm_visualizer .types import Number , Serializable , SerializableSequence , UNDEFINED
53
64
75class GraphTracer (Tracer ):
8- def set (self , array2d : List [ List [Serializable ]] = UNDEFINED ):
6+ def set (self , array2d : SerializableSequence [ SerializableSequence [Serializable ]] = UNDEFINED ):
97 self .command ("set" , array2d )
108
119 def directed (self , isDirected : bool = UNDEFINED ):
1210 self .command ("directed" , isDirected )
1311
14- def weighted (self , isWeighted : bool = UNDEFINED ):
12+ def weighted (self , isWeighted : bool = UNDEFINED ) -> "GraphTracer" :
1513 self .command ("weighted" , isWeighted )
1614 return self
1715
18- def layoutCircle (self ):
16+ def layoutCircle (self ) -> "GraphTracer" :
1917 self .command ("layoutCircle" )
2018 return self
2119
22- def layoutTree (self , root : Serializable = UNDEFINED , sorted : bool = UNDEFINED ):
20+ def layoutTree (self , root : Serializable = UNDEFINED , sorted : bool = UNDEFINED ) -> "GraphTracer" :
2321 self .command ("layoutTree" , root , sorted )
2422 return self
2523
26- def layoutRandom (self ):
24+ def layoutRandom (self ) -> "GraphTracer" :
2725 self .command ("layoutRandom" )
2826 return self
2927
3028 def addNode (
3129 self ,
3230 id : Serializable ,
33- weight : Optional [ Number ] = UNDEFINED ,
31+ weight : Number = UNDEFINED ,
3432 x : int = 0 ,
3533 y : int = 0 ,
3634 visitedCount : int = 0 ,
@@ -41,7 +39,7 @@ def addNode(
4139 def updateNode (
4240 self ,
4341 id : Serializable ,
44- weight : Optional [ Number ] = UNDEFINED ,
42+ weight : Number = UNDEFINED ,
4543 x : int = UNDEFINED ,
4644 y : int = UNDEFINED ,
4745 visitedCount : int = UNDEFINED ,
@@ -56,7 +54,7 @@ def addEdge(
5654 self ,
5755 source : Serializable ,
5856 target : Serializable ,
59- weight : Optional [ Number ] = UNDEFINED ,
57+ weight : Number = UNDEFINED ,
6058 visitedCount : int = UNDEFINED ,
6159 selectedCount : int = UNDEFINED
6260 ):
@@ -66,7 +64,7 @@ def updateEdge(
6664 self ,
6765 source : Serializable ,
6866 target : Serializable ,
69- weight : Optional [ Number ] = UNDEFINED ,
67+ weight : Number = UNDEFINED ,
7068 visitedCount : int = UNDEFINED ,
7169 selectedCount : int = UNDEFINED
7270 ):
@@ -79,15 +77,15 @@ def visit(
7977 self ,
8078 target : Serializable ,
8179 source : Serializable = UNDEFINED ,
82- weight : Optional [ Number ] = UNDEFINED
80+ weight : Number = UNDEFINED
8381 ):
8482 self .command ("visit" , target , source , weight )
8583
8684 def leave (
8785 self ,
8886 target : Serializable ,
8987 source : Serializable = UNDEFINED ,
90- weight : Optional [ Number ] = UNDEFINED
88+ weight : Number = UNDEFINED
9189 ):
9290 self .command ("leave" , target , source , weight )
9391
0 commit comments