Your question is not very clear nor reproducible. For example, I don't know what you mean by an "adjacency array".
That aside, assuming you have a text file (which I call sample.txt
here) with the following content
5vertices,não dirigido
0,1
1,2
1,3
2,3
3,4
4,0
Reinforcement that this is the notation of vertices in the format (v, w).
vertices: 0 to 4
you can use readLines
to read the file line-by-line, extract the edge list and create an igraph
object:
ln <- readLines("sample.txt")
# Store as matrix with from/to indices
vtx <- do.call(rbind, strsplit(ln[grep("\\d+,\\d+", ln)], ","))
# Convert indices to integer and convert to igraph
library(igraph)
ig <- graph_from_data_frame(apply(vtx, 2, as.integer))
plot(ig)
