How to plot a graph with labels for vertices?

I am trying to do use LightGraphs.jl to plot some graphs which is ok but I want t label the vertices and edges too.

I have used MetaGraphs to add metadata to each edge but I can’t seem to find a way to plot the graph with the labels.

Does anyone have tips on what to do?

using LightGraphs, MetaGraphs

mg = MetaGraph(SimpleDiGraph{Int}(1))
add_vertex!(mg.graph)
add_edge!(mg.graph, 2, 1)

using GraphPlot

gplot(mg) # thisoly plots this

image

Check the GraphPlot.jl docs for how to add labels.

1 Like

ah, why didn’t i think of that. Thought it’d be controlled by Meta but actually you can just specify it

1 Like