Weighted Directed Graphs are represented as dictionaries of dictionaries in python. Something like this (example):
digraph = {'a': {'b':2, 'c':3}, 'b': { 'a':1, 'd',2}}
My problem involves passing this digraph object to the Django Template system. In this example 'a', 'b', 'c', 'd' are nodes of the graph and the digraph represents connections between these nodes along with the weight of each connecting edge given by the integer values.
Consider a general node: node.
I am having difficulties in accessing: digraph.node.items , inside the template. For any dictionary D, D.items works well. But not when we want to access the items of a sub-dictionary (in the above digraph). This is what I want exactly (but does NOT work well):
{% for node in node_list %}
{% for adj_node,weight in digraph.node.items %}
{{ adj_node }}, {{ weight }} <br/>
{% endfor %}
{% endfor %}
adj_node and weight are not printed.