harishB97 commited on
Commit
88ac4c8
·
verified ·
1 Parent(s): 35d3b6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -28,7 +28,7 @@ class Node():
28
  def __init__(self, name):
29
  self.name = name
30
  self.parent = None
31
- self.children = []
32
 
33
  def add_child(child):
34
  self.children.append(child)
@@ -36,7 +36,16 @@ class Node():
36
 
37
  name_to_node = {}
38
 
39
- for species, imgpath in species_to_imgpath.items():
 
 
 
 
 
 
 
 
 
40
  for foldername in os.listdir(imgpath):
41
  if os.path.isdir(os.path.join(imgpath, foldername)):
42
  folderpath = os.path.join(imgpath, foldername)
@@ -60,7 +69,8 @@ for species, imgpath in species_to_imgpath.items():
60
 
61
  node.children = child_nodes
62
 
63
- # To be finished
 
64
 
65
 
66
 
@@ -68,7 +78,6 @@ for species, imgpath in species_to_imgpath.items():
68
 
69
  def display_tree():
70
  # This function should create and return a Plotly figure of the tree
71
- # Currently returns a simple string, but should be replaced with actual graph
72
 
73
  # Define the nodes and edges for the graph
74
  nodes = ['Node 1', 'Node 2', 'Node 3', 'Node 4']
 
28
  def __init__(self, name):
29
  self.name = name
30
  self.parent = None
31
+ self.children = [] # list of type Node
32
 
33
  def add_child(child):
34
  self.children.append(child)
 
36
 
37
  name_to_node = {}
38
 
39
+ def get_root(node):
40
+ root = node
41
+ while node:
42
+ root = node
43
+ node = node.parent
44
+
45
+ return root
46
+
47
+ def get_tree(imgpath):
48
+
49
  for foldername in os.listdir(imgpath):
50
  if os.path.isdir(os.path.join(imgpath, foldername)):
51
  folderpath = os.path.join(imgpath, foldername)
 
69
 
70
  node.children = child_nodes
71
 
72
+ # To be finished
73
+ return get_root(node)
74
 
75
 
76
 
 
78
 
79
  def display_tree():
80
  # This function should create and return a Plotly figure of the tree
 
81
 
82
  # Define the nodes and edges for the graph
83
  nodes = ['Node 1', 'Node 2', 'Node 3', 'Node 4']