However, there are some places which are not clear to me at first. After some debug, I decided to put out a simpler version for people to use.
Assuming a Markov chain transition matrix T ( 5x5 matrix) with majority of them are zero.
T(0,0) = 0.1
T(0,1) = 0.2
T(0,3) = 0.7
T(1,1) = 0.9
https://stackoverflow.com/questions/13814640/color-a-particular-node-in-networkx-and-graphviz
import networkx as nx
from networkx.drawing.nx_agraph import to_agraph
G = nx.Graph()
G.add_node(1,color='red',style='filled',fillcolor='blue',shape='square')
G.add_node(2,color='blue',style='filled')
G.add_edge(1,2,color='green')
G.nodes[2]['shape']='circle'
G.nodes[2]['fillcolor']='red'
A = to_agraph(G)
A.layout()
A.draw('color.png')
print(A.to_string())
import networkx as nx
from networkx.drawing.nx_agraph import to_agraph
G = nx.Graph()
G.add_node(1,color='red',style='filled',fillcolor='blue',shape='square')
G.add_node(2,color='blue',style='filled')
G.add_edge(1,2,color='green')
G.nodes[2]['shape']='circle'
G.nodes[2]['fillcolor']='red'
A = to_agraph(G)
A.layout()
A.draw('color.png')
print(A.to_string())
No comments:
Post a Comment