label_largest_component contains disconnected components

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

label_largest_component contains disconnected components

mvdnheuv
Hi,

So I am trying to extract the largest connected component from a network I
have but if I do label_components on the resulting GraphView, it tells me
there are different components within the largest connected components,
which doesn't make sense.

Here is what I do:


In [24]: print(pharma_reach)
Out[24]: <GraphView object, directed, with 16211 vertices and 15527 edges,
edges filtered by (&lt;EdgePropertyMap object with value type 'bool', for
Graph 0x7f9399d88b00, at 0x7f9399d88f28>, False), vertices filtered by
(<VertexPropertyMap object with value type 'bool', for Graph 0x7f9399d88b00,
at 0x7f9399d88eb8>, False) at 0x7f9399d88b00>

This is a network of pharma companies extracted from a larger network. I
then extract the largest component as follows:

In [25]: pharma_reach_lc = GraphView(pharma_reach,
vfilt=label_largest_component(pharma_reach, directed=False))
In [26]: print(pharma_reach_lc)
Out [26]: <GraphView object, directed, with 6798 vertices and 8242 edges,
edges filtered by (&lt;EdgePropertyMap object with value type 'bool', for
Graph 0x7f939417d4a8, at 0x7f939417d588>, False), vertices filtered by
(<VertexPropertyMap object with value type 'bool', for Graph 0x7f939417d4a8,
at 0x7f939417d128>, False) at 0x7f939417d4a8>

So seems to do something. I then plotted the graph and it seemed like there
where disconnected components. So I checked with label_components and get

In [27]: comp, hist = label_components(pharma_reach_lc, directed=False)
In [28]: print(hist)
Out[28]: array([5532,   11,  102,    2,    2,    5,    4,    7,    2,    3,  
13,
          1,   19,    1,    5,    6,    4,    6,    2,    4,    6,    4,
          2,    4,    4,    5,    1,   13,    5,    2,    2,    2,   35,
          6,    2,    5,    7,    4,    1,   23,   18,    7,    5,    6,
          2,    2,    3,    7,    2,    3,    2,   10,    1,    7,    4,
          3,    5,    3,    5,    4,    4,    4,   10,    5,    8,   10,
          2,    4,    2,    6,   16,    4,    6,   11,    7,    4,    3,
         15,    3,    2,    2,    3,    1,    3,    2,    9,   15,    2,
          3,    2,    3,   10,    4,    2,    2,    6,   10,    2,    3,
          2,    5,   10,    1,    4,    3,    5,    2,    1,    6,    3,
          7,    1,    4,    2,    2,    2,    5,    2,    6,    5,    3,
          2,    3,    1,    2,    3,    1,    5,    9,    6,    2,    2,
          1,    4,    2,    5,    2,    2,    1,    1,    2,    6,    7,
          2,    2,    2,    2,    8,    1,    1,    1,    4,    2,    6,
          1,    4,    1,    1,    4,    2,    3,    1,    3,    1,    3,
          6,    4,    1,    3,    4,    1,    4,    4,    1,    4,    2,
          3,    3,    3,    4,    2,    3,    4,    2,    1,    2,    3,
          1,    5,    6,    1,    3,    2,    1,    2,    5,    2,    1,
          4,    3,    8,    2,    9,    5,    5,    2,    5,    2,    4,
          1,    3,    3,    2,    1,    1,    3,    1,    1,    1,    2,
          1,    1,    2,    1,    1,    2,    2,    6,    3,    1,    2,
          2,    1,    2,    2,    3,    1,    3,    1,    2,    2,    3,
          2,    1,    1,    2,    1,    3,    3,    2,    1,    2,    1,
          3,    2,    2,    2,    3,    1,    3,    1,    2,    2,    4,
          1,    3,    2,    2,    4,    2,    2,    3,    1,    1,    1,
          2,    1,    1,    1,    5,    1,    1,    3,    1,    1,    2,
          2,    3,    3,    2,    2,    1,    1,    3,    4,    2,    2,
          2,    2,    1,    2,    4,    1,    2,    1,    1,    1,    1,
          2,    1,    2,    1,    4,    1,    3,    1,    2,    1,    1,
          2,    1,    2,    2,    1,    1,    2,    1,    1,    1,    4,
          1,    1,    2,    1,    2,    1,    2,    1,    1,    1,    2,
          2,    2,    1,    2,    1,    2,    1,    1,    1,    1,    2,
          2,    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
          1,    1,    1,    1,    1,    1,    1], dtype=uint64)

but even if I again select this first component, it does not subselect any
nodes, it just returns the same set.

In [29]:
pharma_reach_lc_check = GraphView(pharma_reach_lc, vfilt=comp.fa==0)
In [30]: print(pharma_reach_lc_check)
Out[30]: <GraphView object, directed, with 6798 vertices and 8242 edges,
edges filtered by (&lt;EdgePropertyMap object with value type 'bool', for
Graph 0x7f939417deb8, at 0x7f93941f1cf8>, False), vertices filtered by
(<VertexPropertyMap object with value type 'bool', for Graph 0x7f939417deb8,
at 0x7f93941f1f98>, False) at 0x7f939417deb8>

I've been checking different ways but all end up the same. What's going
wrong here?

ps I have version '2.29 (commit 74b5946a, )' because I work on a university
server that is a pain to update regularly in case this was a known bug.



--
Sent from: https://nabble.skewed.de/
_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool
Reply | Threaded
Open this post in threaded view
|

Re: label_largest_component contains disconnected components

Tiago Peixoto
Administrator
Am 02.09.20 um 21:32 schrieb mvdnheuv:
> Here is what I do:

I can't reproduce the behavior you see with a simple example.

If you want concrete help, you need to provide us with a minimal and
self-contained example that shows the problem.

> ps I have version '2.29 (commit 74b5946a, )' because I work on a university
> server that is a pain to update regularly in case this was a known bug.

This is a very old release, and you should definitely upgrade.

--
Tiago de Paula Peixoto <[hidden email]>


_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool

signature.asc (849 bytes) Download Attachment
--
Tiago de Paula Peixoto <tiago@skewed.de>