|
From: | Filippo Santi |
Subject: | Re: [igraph] Converting Igraph object to adjacency matrix of class "matrix" |
Date: | Tue, 27 Feb 2018 10:50:37 +0100 |
Hi, set sparse = FALSE in as_adjacency_matrix.
Gabor
> ______________________________
On Tue, Feb 27, 2018 at 8:30 AM, Filippo Santi <address@hidden> wrote:
> Hello Everyone,
>
> I am trying to obtain an adjacency matrix from a graph object, as I have to
> perform some manipulation before reconverting it to a graph to obtain the
> statistics I need.
>
> However, I am stuck with a dgcMatrix, as I am not able to convert it to a
> standard "matrix" class adjacency matrix.
>
> Below the code I am using:
>
> # Creating network from edgelist
> undesa.overind.1990 <- graph.data.frame(edge, vertices = vert, directed = T)
> undesa.overind.1990 <- set_edge_attr(undesa.overind.1990, 'weight', value =
> get.edge.attribute(undesa.overind.1990, 'stock_od'))
>
> # Extracting adjacency matrix
> adjac <- as_adjacency_matrix(undesa.overind.1990, edges = T, names = T, attr
> = 'weight')
> class(adjac) #dgMatrix
>
> I tried to convert with
>
> as(adjac, "matrix")
>
> However, what I get is a matrix with "the non-zero elements in the columns
> sorted into increasing row order", as explained by the dgCMatrix help file,
> rather than the adjacency matrix.
>
> How could I solve this issue, to retrieve the adjacency matrix from my
> graph? I could not find any useful help online.
>
> Best,
>
> Filippo
>
> --
> Filippo Santi
> PhD Candidate in Development Economics
>
>
_________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>
_______________________________________________
igraph-help mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help
[Prev in Thread] | Current Thread | [Next in Thread] |