Plotting graphs, using GraphPlot

Hello,
I would like to draw a graph with node and edge labels. I am stuck as when I call gplot no edges appear in my graph. I attatched an image of my graph as well as what I would like

using LightGraphs
using GraphPlot
using Compose
g = SimpleGraph(5)
add_edge!(g,1,3)
gplot(g)

26%20PM

gplot sometimes shows edges a bit weird, but you have an edge between the close nodes on the top right. If you want to label your nodes/edges you can do that with

g = graphfamous("karate")

labels_edge = collect(1:ne(g))
labels_node = collect(1:nv(g))

gplot(g,
    nodelabel = labels_node,
    edgelabel = labels_edge)

Can we change the labels to be something else?

Sure. Try an array with the length of the total number of edges containig your desired edge labels:

labels_edge = ["my", "edge", "labels",...,"foo", "bar"]
1 Like