Peter
Peter

Reputation: 355

Actual distances in igraph

I am trying to plot 3 points with igraph and I would like to preset the distances between the three points. Example

A = matrix( 
     0, 
     nrow=3,              # number of rows 
     ncol=3,              # number of columns 
     byrow = TRUE)        # fill matrix by rows 

A[1,2]=5
A[2,3]=4
A[1,3]=3
g <- graph.adjacency(A)
plot(g)

I would like the output to be a triangle with a rectangular angle. However the distances between the points seem pretty much the same. How can I solve this?

Best Alex

Upvotes: 1

Views: 460

Answers (1)

Ven Yao
Ven Yao

Reputation: 3710

g <- graph.adjacency(A, mode="undirected", weighted=T)
plot(g, layout=layout_with_kk)

enter image description here

Upvotes: 1

Related Questions