Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201894

How to create a graph from an adjacency matrix by also specifying nodes coordinates in igraph?

$
0
0

I have the following R code:

library('igraph')

nodes <- c('a','b','c','d')
x <- c(0,1,2,3)
y <- c(0,1,2,3)

from <- c('a','b','c')
to <- c('b','c','d')

NodeList <- data.frame(nodes, x ,y)
EdgeList <- data.frame(from, to)

plot(graph_from_data_frame(vertices = NodeList, d= EdgeList, directed = FALSE))

Which emits the graph I want. However I need to be able to use the adjacency matrix instead of from and to vectors. Function graph_from_adjacency_matrix does not include a parameter to specify the coordinates of nodes. How to achieve this?


Viewing all articles
Browse latest Browse all 201894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>