nodes

Printing binary tree after initialising gives None value

Printing binary tree after initialising gives None value Question: I have a simple binary tree. I have intialized it using TreeNode class, but while printing out the values from the tree, it gives me None value as well. How to mitigate this? The code snippet is as follows: class TreeNode: def __init__(self, root=None, left = …

Total answers: 2

Linked List, can't acess the data from NEXT NODE

Linked List, can't acess the data from NEXT NODE Question: My problem is at the display function, I can’t access the value cur_node.data which is a reference to node.next.data. I’m new to python and I’m trying to learn Linked LISTS, this code is from an old VIDEO which is why it probably isn’t working My …

Total answers: 1

length of the values of any given key

length of the values of any given key Question: I am trying to create a function that will return the degrees of a given node in a graph. I keep running into the error unhashable type: ‘list’ in my degree function and I’m not really sure why this is happening since I am not trying …

Total answers: 1

Program to generate all the possible paths from one node to the other

Program to generate all the possible paths from one node to the other Question: I wanted to generate all the possible paths from one node to the other with this program: graph = { "a" : ["b","c"], "b" : ["a", "d"], "c" : ["a", "d"], "d" : ["e"], "e" : ["b"] } def find_all_paths(graph, start, …

Total answers: 2

Get selected node names into a list or tuple in Nuke with Python

Get selected node names into a list or tuple in Nuke with Python Question: I am trying to obtain a list of the names of selected nodes with Python in Nuke. I have tried: for s in nuke.selectedNodes(): n = s[‘name’].value() print n This gives me the names of the selected nodes, but as separate …

Total answers: 2

How can one modify the outline color of a node In networkx?

How can one modify the outline color of a node In networkx? Question: I am relatively new to networkx and plotting using matplotlib.pyplot and would like to know how to modify the color (or other attributes such as weight) of a node’s outline. By “outline” I don’t mean an arc or edge between two nodes; …

Total answers: 4

Python networkx : edge contraction

Python networkx : edge contraction Question: I have a NetworkX graph. I would like to know how to do edge contraction between multiple nodes. For example, if I wanted to contract X, Y and Z: _ node A _ _/ | _ node X — node Y — node Z Would become node A | …

Total answers: 2