GraphViews of GraphViews??

Hi!

I am trying to subset my graph to a smaller graph which I do by making a view of the original graph. Then from that graph I want to keep the largest component. Hence, I do another GraphView of that former GraphView. This does for some reason not work. Aren't graph view supposed to work on graph views themselfes. The solution which is now working for me is:

        gPath_ind = [ eg2id[e] for e in egPath ]
        gPath_filt = g.new_vertex_property("bool")
        gPath_filt.a[:] = False
        gPath_filt.a[gPath_ind] = True
        gp = GraphView(g, vfilt=gPath_filt)
        gpl = label_largest_component(gp)
        path_lc = []
        for v in gp.vertices():
            if(gpl[v]):
                path_lc.append(int(v))

The more elegant solution

        gPath_ind = [ eg2id[e] for e in egPath ]
        gPath_filt = g.new_vertex_property("bool")
        gPath_filt.a[:] = False
        gPath_filt.a[gPath_ind] = True
        gp = GraphView(g, vfilt=gPath_filt)
        gpl = GraphView(gp, vfilt=label_largest_component(gp))
  path_lc = [ int(v) for v in gpl.vertices() ]

fails for some reason I don't see. BTW, in the end I want the vertex indices in the very original graph, which is what I hope to get here, but I am not really sure about that as I could not find anything about how to obtain vertex identifiers of filtered graphs which are good for referring to nodes in the original un-filtered graph. Or I overlooked it somewhere...

BTW, the newest graph-tool seems to compile and install just fine on MacOS. At least it brings its own DLFCN.py and hence installing out of the box.

Cheers,

The more elegant solution

        gPath_ind = [ eg2id[e] for e in egPath ]
        gPath_filt = g.new_vertex_property("bool")
        gPath_filt.a[:] = False
        gPath_filt.a[gPath_ind] = True
        gp = GraphView(g, vfilt=gPath_filt)
        gpl = GraphView(gp, vfilt=label_largest_component(gp))
        path_lc = [ int(v) for v in gpl.vertices() ]

fails for some reason I don't see.

I guess the problem is a small quirk with label_largest_component().
The code above removes all but one vertex, which has index gPath_ind,
from the graph (is this really what you want, BTW?). The function
label_largest_component() marks all the vertices which have the same
index as the largest component. Since there is only one vertex, the
component index is zero. However, the _unfiltered_ vertices will also
have an index of zero, and they will get labelled as well... So your
GraphView in the end will contain all the vertices.

I have fixed this now in the git version (now
label_largest_component() never labels filtered graphs).

BTW, in the end I want the vertex indices in the very original
graph, which is what I hope to get here, but I am not really sure
about that as I could not find anything about how to obtain vertex
identifiers of filtered graphs which are good for referring to nodes
in the original un-filtered graph. Or I overlooked it somewhere...

The vertex index is preserved by filtering. So you could do something like:

    v = g.vertex(int(u))

where u belongs to the filtered graph, and g is the unfiltered graph.

BTW, the newest graph-tool seems to compile and install just fine
on MacOS. At least it brings its own DLFCN.py and hence installing
out of the box.

What do you mean? I haven't included DLFCN.py anywhere... (I can't
anyway, since it is platform-dependent code)

Cheers,
Tiago

Hi!

       gPath_ind = [ eg2id[e] for e in egPath ]
       gPath_filt = g.new_vertex_property("bool")
       gPath_filt.a[:] = False
       gPath_filt.a[gPath_ind] = True
       gp = GraphView(g, vfilt=gPath_filt)
       gpl = GraphView(gp, vfilt=label_largest_component(gp))
       path_lc = [ int(v) for v in gpl.vertices() ]

fails for some reason I don't see.

I guess the problem is a small quirk with label_largest_component().
The code above removes all but one vertex, which has index gPath_ind,
from the graph (is this really what you want, BTW?). The function

gPath_ind is a list of indices of vertices I wanna keep in the filtered view of the graph, i.e. definitely more than one vertex. From that set of vertices I want to extract the largest component.

The vertex index is preserved by filtering. So you could do something like:

   v = g.vertex(int(u))

where u belongs to the filtered graph, and g is the unfiltered graph.

That is what I assumed, but good to have that confirmed. Thanks

BTW, the newest graph-tool seems to compile and install just fine
on MacOS. At least it brings its own DLFCN.py and hence installing
out of the box.

What do you mean? I haven't included DLFCN.py anywhere... (I can't
anyway, since it is platform-dependent code)

Hmm, I thought I deleted it manually, but obviously not. Anyway, if one puts the DLFCN.py into the graph-tool directory, it runs fine here. So I guess we should file a bug to macports regarding the python installation (in the meantime I reinstalled Xcode and python such that I have a proper macports installation of python 2.7).

CU,

Sebastian

Hi!

       gPath_ind = [ eg2id[e] for e in egPath ]
       gPath_filt = g.new_vertex_property("bool")
       gPath_filt.a[:] = False
       gPath_filt.a[gPath_ind] = True
       gp = GraphView(g, vfilt=gPath_filt)
       gpl = GraphView(gp, vfilt=label_largest_component(gp))
       path_lc = [ int(v) for v in gpl.vertices() ]

fails for some reason I don't see.

I guess the problem is a small quirk with label_largest_component().
The code above removes all but one vertex, which has index gPath_ind,
from the graph (is this really what you want, BTW?). The function

gPath_ind is a list of indices of vertices I wanna keep in the
filtered view of the graph, i.e. definitely more than one vertex. From
that set of vertices I want to extract the largest component.

Oh, I see now. I misunderstood the first line of your code. But in any
case, I think I had correctly identified the bug, which should always
happen when the largest component has an index of zero. Could you see if
things work now with the git version?

BTW, the newest graph-tool seems to compile and install just fine
on MacOS. At least it brings its own DLFCN.py and hence installing
out of the box.

What do you mean? I haven't included DLFCN.py anywhere... (I can't
anyway, since it is platform-dependent code)

Hmm, I thought I deleted it manually, but obviously not. Anyway, if
one puts the DLFCN.py into the graph-tool directory, it runs fine
here. So I guess we should file a bug to macports regarding the python
installation (in the meantime I reinstalled Xcode and python such that
I have a proper macports installation of python 2.7).

Yes, we should file a bug report. There is no possible workaround we can
do from graph-tool, since the contents of DLFCN.py will be different in
each platform.

Cheers,
Tiago

Hi!

Oh, I see now. I misunderstood the first line of your code. But in any
case, I think I had correctly identified the bug, which should always
happen when the largest component has an index of zero. Could you see if
things work now with the git version?

For some reason ccache is not working; therefore I will tell you later today... argh I hate compiling graph-tool...

BTW, the newest graph-tool seems to compile and install just fine
on MacOS. At least it brings its own DLFCN.py and hence installing
out of the box.

What do you mean? I haven't included DLFCN.py anywhere... (I can't
anyway, since it is platform-dependent code)

Hmm, I thought I deleted it manually, but obviously not. Anyway, if
one puts the DLFCN.py into the graph-tool directory, it runs fine
here. So I guess we should file a bug to macports regarding the python
installation (in the meantime I reinstalled Xcode and python such that
I have a proper macports installation of python 2.7).

Yes, we should file a bug report. There is no possible workaround we can
do from graph-tool, since the contents of DLFCN.py will be different in
each platform.

Yup. Do you go ahead?

CU,

Sebastian

It is a python-only modification, so you should be able just to copy the
__init__.py file from the topology module to your installation, if you
are in a hurry.

Cheers,
Tiago