Questions tagged [anytree]

anytree is a Lightweight Python Tree Data Structure.

67 questions
0
votes
1 answer

Copying an AnyTree in Python

I want to take the node of a tree created with AnyTree and copy the whole tree so I can make changes to it without changing the original. The only thing that I can think of is looping through the whole tree and copying the nodes one by one adding…
Lilly
  • 111
  • 1
  • 8
0
votes
0 answers

Python anytree - not of type 'NodeMixin' Error

I am trying to build a Hierarchy from the below csv data: Child,Parent,IsActive 11074165,11018432,NO 11094122,11033371,NO 11020499,11018277,NO 11018432,11020499,NO Below is the code snippet nodes = {} with open("SampleHierarchy.csv", "r") as f: …
georgeb
  • 1
  • 2
0
votes
1 answer

Python - tkinter: Resize Treeview horizontally

To illustrate big trees from anytree in tkinter I use Treeview. My aim is to horizontally adjust (dynamically) the size of the column where the data of the Treeview object is stored after resizing the window. I tried to put the Treeview object…
Martin Kunze
  • 995
  • 6
  • 16
0
votes
1 answer

Visualizing a tree with nodes of different colors with anytree

I am looking for a simple way to construct and draw a tree (on google colab). Importantly, I would like to have nodes of different colors and shapes. Ideally, I would like something as follows. from anytree import Node, RenderTree from…
grg
  • 85
  • 7
0
votes
1 answer

Anytree Module/UniqueDotExporter produces a Tree with redundant edges

so I got the following problem. I am building a tree that shows dependencies with the Python Module anytree. Nodes are created with: Node(""+str(name), parent= parentname) at the end of my program I want to create a graph with…
Iceqbe
  • 1
  • 1
0
votes
1 answer

Anytree to Pandas or tuple conversion with node members as indices

I'd like to build a pandas dataframe or tuple from an anytree object, where each node has a list attribute of members: from anytree import Node, RenderTree, find_by_attr from anytree.exporter import DictExporter from collections import…
0
votes
2 answers

Adding new nodes by id in anytree

I'm trying to implement a tree with unique IDs per 'section' nodes and unique IDs for each child node in each section. I wonder how to accomplish this with anytree (python). I tried this: from anytree import AnyNode, RenderTree, Resolver class…
apio
  • 154
  • 11
0
votes
1 answer

Why is my PLY parser not grouping anytree nodes together properly?

I am trying to build a CAS in Python and am currently stuck on implementing the parser I will use to go from expression string to an Anytree tree I can eventually manipulate and simplify. The issue seems to be that, when parsing, yacc doesn't…
0
votes
1 answer

Generate tree from file with indents using anytree

I'm using anytree to generate a tree from a file, Tree.txt. Each indent is 3 spaces ( ). Here's what my file looks like: ROOT Node1 Node2 Node3 Node4 Node5 Node6 And here's what I have so far for the generating…
aheze
  • 24,434
  • 8
  • 68
  • 125
0
votes
1 answer

Python anytree: When iterating, know when branch is closed

Using example from documentation: from anytree import Node, RenderTree, AsciiStyle f = Node("f") b = Node("b", parent=f) a = Node("a", parent=b) d = Node("d", parent=b) c = Node("c", parent=d) e = Node("e", parent=d) g = Node("g", parent=f) i =…
beginner_
  • 7,230
  • 18
  • 70
  • 127
0
votes
1 answer

anytree nodemixin using property or reference

I have an existing tree and I would like to add anytree functionality by adding NodeMixin. The problem is that NodeMixin wants a fixed name 'children' for its sub-elements and I already have a list with a different name. Another problem (I am using…
uuu777
  • 765
  • 4
  • 21
0
votes
1 answer

How do I reverse the direction of arrows in my python anytree graphviz output?

I am building trees that are designed to represent a flow from leaves to the root of the tree using the anytree package in python. I have the following code. from anytree import Node from anytree.exporter import DotExporter A = Node('A') B =…
Max Feinberg
  • 810
  • 1
  • 6
  • 21
0
votes
1 answer

Generate ID for each node in a tree

I constructed a tree using anytree module in python. The code is as follows: def list_anytree(lst): rootname = lst[0][0] node = Node(rootname) for j in lst: parentnode = node assert j[0] == parentnode.name for…
Rahul
  • 3
  • 3
0
votes
1 answer

How to fix this error? FileNotFoundError: [WinError 2] The system cannot find the file specified

My code is like this: from anytree import Node, RenderTree from anytree.exporter import DotExporter udo = Node("Udo") marc = Node("Marc", parent=udo) lian = Node("Lian", parent=marc) dan = Node("Dan", parent=udo) jet = Node("Jet", parent=dan) jan =…
Srushti Parab
  • 31
  • 2
  • 8
0
votes
0 answers

Accessing nested object values from MongoDB

I have a collection in MongoDB of nested objects (basically a tree structure). I am trying to access certain "id" and "user_id" values in "children". The collection looks like this: Image of a tree object in MongoDB When I query "children" I get,…