Very Simple Social Network

I want to import a simple CSV into R with the following:

Vertex1, Vertex2, Edge_Label
Jack, Jill, Friends
Mum,Dad,Married
Mum,Jack, Parent
Bill,Ben, Colleague

I have seen reams of material on how to name and configure the vertex-label, but am damned if I can find a simple way to add the Label to each of the Edges.

Needs to look something like this: Jack (node) -------------------Friends (label)-----------Jill (node).

Please help . . . . :slight_smile:

Could you perhaps clarify in which language you would like to do this? Python, R, Mathematica?

Thanks, Iโ€™m using R. iโ€™ve amended the original post with that info, thanks for pointing it out.

Have found a basic solution as follows

'R script
library(igraph)
cat(โ€œ\014โ€)
myDataFile โ† read.csv(โ€œC://Users/grego//Dropbox//Projects//R//Sociogram/sociogram.txtโ€)
myDataFile
g โ† graph.data.frame(myDataFile)

plot(g,
layout=layout.circle,
edge.label = E(g)$Type)

'Data File
V1 V2 Type
1 9 4 hairdresser
2 3 2 served time with
3 1 6 went out with
4 9 5 canโ€™t stand
5 11 2 likes
6 11 14 secretly likes
7 You Me blackmailed
8 1 7 stole from
9 7 4 lied to
10 3 9 drove home
11 Mary Jack washed
12 2 8 dentist
13 1 8 stole car
14 6 8 cut grass
15 12 4 burg
16 George Mary cares for
17 21 13 married
18 4 Mary murdered
19 1 3 abducted
20 7 12 spiritual advisor
21 11 10 spaghetti

Now to make it pretty . . . .

image

Great you found a solution yourself! You can explore different layout functions to try to make it prettier, such as layout.reingold.tilford. Let us know what you get! If you have any other questions, let us know.