Discussion:
[igraph] knn computation
Filippo Santi
2018-01-23 18:29:46 UTC
Permalink
Dear all,

I am new to R and even more to igraph. I am working on foreign direct
investment network, and I am currently trying to compute average nearest
neighbour degree and average nearest neighbour strength, using the knn
function. My code is as following:

fdi.graph.2003 <- graph_from_data_frame(fdi.edge.2003, directed = T,
vertices = fdi.attr.2003)
ANND <- knn(fdi.graph.2003)

However, R returns the following error message

Error in knn(fdi.graph.2003) :
At structural_properties.c:5889 : Average nearest neighbor degree Works
only with simple graphs, Invalid value

Do you have any explanation to try to solve this issue? I tried to compute
it building the graph from a simple binary edgelist too (the above message
comes from computations based on a weighted network with plenty of edge
attributes, built from a data.frame) but it is not working either.


Thanks for any help,


Filippo
Szabolcs Horvát
2018-01-23 20:10:08 UTC
Permalink
Hi Filippo,

The message means that your graph has either self-loops (an edge
connecting a vertex to itself), or parallel edges connecting the same
two vertices. The function does not work on such graphs. You need to
supply a simple graph—take a look at simplify().

Also, be aware that knn() does not compute the mean neighbour strength
for weighted graphs. https://github.com/igraph/igraph/issues/987

Szabolcs
Post by Filippo Santi
Dear all,
I am new to R and even more to igraph. I am working on foreign direct
investment network, and I am currently trying to compute average nearest
neighbour degree and average nearest neighbour strength, using the knn
fdi.graph.2003 <- graph_from_data_frame(fdi.edge.2003, directed = T,
vertices = fdi.attr.2003)
ANND <- knn(fdi.graph.2003)
However, R returns the following error message
At structural_properties.c:5889 : Average nearest neighbor degree Works only
with simple graphs, Invalid value
Do you have any explanation to try to solve this issue? I tried to compute
it building the graph from a simple binary edgelist too (the above message
comes from computations based on a weighted network with plenty of edge
attributes, built from a data.frame) but it is not working either.
Thanks for any help,
Filippo
_______________________________________________
igraph-help mailing list
https://lists.nongnu.org/mailman/listinfo/igraph-help
Filippo Santi
2018-01-25 08:33:49 UTC
Permalink
Dear Szabolcs,

Than you for the reply. I will check for these issues you mentioned, even
if I should have created the network without allowing for self loops.
Instead, I don't have clear what you mean for "parallel edges connecting
the same two vertices": is it related with the possibility of having more
edge attributes in the graph or is it related to the multiplexity of the
graph?

Filippo
Post by Szabolcs Horvát
Hi Filippo,
The message means that your graph has either self-loops (an edge
connecting a vertex to itself), or parallel edges connecting the same
two vertices. The function does not work on such graphs. You need to
supply a simple graph—take a look at simplify().
Also, be aware that knn() does not compute the mean neighbour strength
for weighted graphs. https://github.com/igraph/igraph/issues/987
Szabolcs
Post by Filippo Santi
Dear all,
I am new to R and even more to igraph. I am working on foreign direct
investment network, and I am currently trying to compute average nearest
neighbour degree and average nearest neighbour strength, using the knn
fdi.graph.2003 <- graph_from_data_frame(fdi.edge.2003, directed = T,
vertices = fdi.attr.2003)
ANND <- knn(fdi.graph.2003)
However, R returns the following error message
At structural_properties.c:5889 : Average nearest neighbor degree Works
only
Post by Filippo Santi
with simple graphs, Invalid value
Do you have any explanation to try to solve this issue? I tried to
compute
Post by Filippo Santi
it building the graph from a simple binary edgelist too (the above
message
Post by Filippo Santi
comes from computations based on a weighted network with plenty of edge
attributes, built from a data.frame) but it is not working either.
Thanks for any help,
Filippo
_______________________________________________
igraph-help mailing list
https://lists.nongnu.org/mailman/listinfo/igraph-help
_______________________________________________
igraph-help mailing list
https://lists.nongnu.org/mailman/listinfo/igraph-help
--
Filippo Santi
PhD Candidate in Development Economics
Szabolcs Horvát
2018-01-25 13:05:41 UTC
Permalink
Hello Filippo,

By "parallel edges" I meant more than one edge connecting the same two
graph vertices. The function works only if this never happens.

Szabolcs
Post by Filippo Santi
Dear Szabolcs,
Than you for the reply. I will check for these issues you mentioned, even if
I should have created the network without allowing for self loops. Instead,
I don't have clear what you mean for "parallel edges connecting the same two
vertices": is it related with the possibility of having more edge attributes
in the graph or is it related to the multiplexity of the graph?
Filippo
Post by Szabolcs Horvát
Hi Filippo,
The message means that your graph has either self-loops (an edge
connecting a vertex to itself), or parallel edges connecting the same
two vertices. The function does not work on such graphs. You need to
supply a simple graph—take a look at simplify().
Also, be aware that knn() does not compute the mean neighbour strength
for weighted graphs. https://github.com/igraph/igraph/issues/987
Szabolcs
Post by Filippo Santi
Dear all,
I am new to R and even more to igraph. I am working on foreign direct
investment network, and I am currently trying to compute average nearest
neighbour degree and average nearest neighbour strength, using the knn
fdi.graph.2003 <- graph_from_data_frame(fdi.edge.2003, directed = T,
vertices = fdi.attr.2003)
ANND <- knn(fdi.graph.2003)
However, R returns the following error message
At structural_properties.c:5889 : Average nearest neighbor degree Works only
with simple graphs, Invalid value
Do you have any explanation to try to solve this issue? I tried to compute
it building the graph from a simple binary edgelist too (the above message
comes from computations based on a weighted network with plenty of edge
attributes, built from a data.frame) but it is not working either.
Thanks for any help,
Filippo
_______________________________________________
igraph-help mailing list
https://lists.nongnu.org/mailman/listinfo/igraph-help
_______________________________________________
igraph-help mailing list
https://lists.nongnu.org/mailman/listinfo/igraph-help
--
Filippo Santi
PhD Candidate in Development Economics
_______________________________________________
igraph-help mailing list
https://lists.nongnu.org/mailman/listinfo/igraph-help
Filippo Santi
2018-01-25 13:28:06 UTC
Permalink
Ok, I think I got the point.
Thank you a lot.

Filippo
Post by Szabolcs Horvát
Hello Filippo,
By "parallel edges" I meant more than one edge connecting the same two
graph vertices. The function works only if this never happens.
Szabolcs
Post by Filippo Santi
Dear Szabolcs,
Than you for the reply. I will check for these issues you mentioned,
even if
Post by Filippo Santi
I should have created the network without allowing for self loops.
Instead,
Post by Filippo Santi
I don't have clear what you mean for "parallel edges connecting the same
two
Post by Filippo Santi
vertices": is it related with the possibility of having more edge
attributes
Post by Filippo Santi
in the graph or is it related to the multiplexity of the graph?
Filippo
Post by Szabolcs Horvát
Hi Filippo,
The message means that your graph has either self-loops (an edge
connecting a vertex to itself), or parallel edges connecting the same
two vertices. The function does not work on such graphs. You need to
supply a simple graph—take a look at simplify().
Also, be aware that knn() does not compute the mean neighbour strength
for weighted graphs. https://github.com/igraph/igraph/issues/987
Szabolcs
Post by Filippo Santi
Dear all,
I am new to R and even more to igraph. I am working on foreign direct
investment network, and I am currently trying to compute average nearest
neighbour degree and average nearest neighbour strength, using the knn
fdi.graph.2003 <- graph_from_data_frame(fdi.edge.2003, directed = T,
vertices = fdi.attr.2003)
ANND <- knn(fdi.graph.2003)
However, R returns the following error message
At structural_properties.c:5889 : Average nearest neighbor degree
Works
Post by Filippo Santi
Post by Szabolcs Horvát
Post by Filippo Santi
only
with simple graphs, Invalid value
Do you have any explanation to try to solve this issue? I tried to compute
it building the graph from a simple binary edgelist too (the above message
comes from computations based on a weighted network with plenty of
edge
Post by Filippo Santi
Post by Szabolcs Horvát
Post by Filippo Santi
attributes, built from a data.frame) but it is not working either.
Thanks for any help,
Filippo
_______________________________________________
igraph-help mailing list
https://lists.nongnu.org/mailman/listinfo/igraph-help
_______________________________________________
igraph-help mailing list
https://lists.nongnu.org/mailman/listinfo/igraph-help
--
Filippo Santi
PhD Candidate in Development Economics
_______________________________________________
igraph-help mailing list
https://lists.nongnu.org/mailman/listinfo/igraph-help
_______________________________________________
igraph-help mailing list
https://lists.nongnu.org/mailman/listinfo/igraph-help
--
Filippo Santi
PhD Candidate in Development Economics
Loading...