igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Error in using the function subcomponent( )


From: address@hidden
Subject: Re: [igraph] Error in using the function subcomponent( )
Date: Tue, 25 Feb 2014 10:01:54 +0800


Thank you.
 

address@hidden
 
Date: 2014-02-24 22:45
Subject: Re: [igraph] Error in using the function subcomponent( )
On Mon, Feb 24, 2014 at 9:29 AM, address@hidden <address@hidden> wrote:
Hi!
 
Thanks for your kind reply. But I still have two question about the function subcomponent( ):
 
1. Should not the result of " subcomponent(g, 4, "all")" be the union of "subcomponent(g, 4, "in")" and "subcomponent(g, 4, "out")"?

No. Just calculate it by hand for your graph.
 
2. The graph is a directed network with 10 vertices and 10 edges and the vertice 0 is an isolated node.
Yes, because vertices are numbered from zero in an 'edgelist' file.
Even if  4 in the source code is 5 in the graph, the result of subcomponent(g, 4, "out") is supposed to be NULL, because there is no vertice could be reached from vertice 5 in graph.
You need to add one to the numbers in the file, to get the ids in R igraph. So when you write subcomponent(g, 4, "out") that belongs to vertex 3 in your file. Which does have an outgoing edge, so subcomponent(g, 4, "out") will be c(4, 3) I guess

The result will never be NULL, anyway, as it always contains the vertex itself.

G.
 
 
Here is the graph: 
1   5
1   7
3   2
4   5
4   7
4   9
9   4
6   9
8   7
9   2
 
best
Xueming
 

 
Date: 2014-02-23 23:42
Subject: Re: [igraph] Error in using the function subcomponent( )
Hi!


On Sun, Feb 23, 2014 at 9:43 AM, address@hidden <address@hidden> wrote:
Hello!
 
I am trying to use the subcomponent() to find the in-component and out-component from a given vertice.
Here is the source code and result:
 
> g<-read.graph("input.txt", "edgelist")

The "edgelist" file format is indexed from zero, so what is 4 in your file will be 5 in your graph.

Gabor
 
> subcomponent(g, 4, "in")
[1] 4
> subcomponent(g, 4, "out")
[1] 4 3
> subcomponent(g, 4, "all")
[1]  4  3 10  5  7  6  8  2  9
 
Here is the input file "input.txt" (a directed network with 10 nodes and 10 edges):
1   5
1   7
3   2
4   5
4   7
4   9
9   4
6   9
8   7
9   2
 
But the actual result is should be:
subcomponent(g, 4, "in"):  4 6 9
subcomponent(g, 4, "out"):  2 4 5 7 9
subcomponent(g, 4, "all"):  2 4 5 6 7 9
 
Why is the results computed by using the function subcomponent( ) different from the actual result?
 
best
Xueming
 


_______________________________________________
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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]