I am trying to create an igraph graph using the co-ordinates of nodes. I realized that there are no direct ways to do this through the igraph package for R.
There are ways to plot a graph on a 2D space using the layout()
function, but I need to create a graph from known co-ordinates of nodes. I'll appreciate any help anyone can provide with this.
Why I'm trying to set up a graph this way? After parametrizing the graph nodes with co-ordinates, I want to connect the nodes using a probability measure that takes the distance between the nodes into account.
Thanks. Hitaysh
# Initial Co-ordinates of nodes
n = 1000 # no. of nodes
nodes.coord <- data.frame(x=runif(n,min=0,max=n),
y=runif(n,min=0,max=n))
# Set up a graph with nodes on above co-ordinates...
P.S. This is my first post on StackOverflow. Any constructive feedback on how to ask questions better, is also welcome.
layout=
parameter inplot.igraph()
(see?igraph::layout
). The xy coordinates tell you nothing about which nodes are connected. Please read how to create a reproducible example and include sample input and desired output. (If you're going to use a runif, also useset.seed()
so we can get the same values). – MrFlick