adj is a numpy array in python
from igraph import *
g = Graph.Adjacency(adj.tolist())
plot(g)
The image has not labels of vertices, only nodes and edges. How can I enable plot to show label or vertex sequence? Thanks,
You can specify the labels to show as a list in the vertex_label
keyword argument to plot()
:
plot(g, vertex_label=["A", "B", "C"])
If the vertices in your graph happen to have a vertex attribute named label
, igraph will use those on the plot by default, so you can also do this:
g.vs["label"] = ["A", "B", "C"]
plot(g)
See the documentation of the Graph.__plot__
function for more details. (plot()
is just a thin wrapper that calls the __plot__
method of whichever object you pass to it as the first argument).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With