[graph-tool] Accessibility from C++

2019-01-10 Thread Gerion Entrup
Hi,

I need a graph library that is accessible for both Python and C++
together with a few other requirements.

graph-tool seems to fulfill all this requirements. However, I don't find
any information whether the library is usable from C++ code as well.

My project consists out of several modules that are all aware a one main
graph object. Each module can be written either in Python or C++. The
modules itself are managed with some Python code.

So my question is: Is it possible to get the C++ graph object out of the
Python graph object? Is it possible to fill the C++ graph object
directly with nodes and edges?

Another point is that I need to attach a pointer (or shared_ptr) to a
custom C++ type to some nodes. The pointer does not need to be
accessible or visible from Python. Is this possible in a simple way?
(Of course I can workaround with an e.g. map of type (vertex id,
pointer).)

Regards,
Gerion


signature.asc
Description: This is a digitally signed message part.
___
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool


[graph-tool] Accessibility from C++

2019-01-10 Thread Tiago de Paula Peixoto
Am 10.01.19 um 13:48 schrieb Gerion Entrup:
> So my question is: Is it possible to get the C++ graph object out of the
> Python graph object? Is it possible to fill the C++ graph object
> directly with nodes and edges?

This is possible, and not very difficult. However, it's undocumented at the
moment.

I'm working on some documentation, and I'll release it soon.

> Another point is that I need to attach a pointer (or shared_ptr) to a
> custom C++ type to some nodes. The pointer does not need to be
> accessible or visible from Python. Is this possible in a simple way?
> (Of course I can workaround with an e.g. map of type (vertex id,
> pointer).)

You can either use a property map of type int64_t, which is enough to hold
pointers. You can also use type python::object, which will hold whatever you
can express in python, inclusive custom classes.

-- 
Tiago de Paula Peixoto 





signature.asc
Description: OpenPGP digital signature
___
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool


Re: [graph-tool] graph-tool example failure

2019-01-10 Thread Tiago de Paula Peixoto
Am 09.01.19 um 00:01 schrieb Moritz Warning:
> Hi,
> 
> I tried to following:
> 
> $ docker run -it -u user -w /home/user tiagopeixoto/graph-tool ipython
> Python 3.6.5 (default, May 11 2018, 04:00:52) 
> Type 'copyright', 'credits' or 'license' for more information
> IPython 6.3.1 -- An enhanced Interactive Python. Type '?' for help.
> 
> In [1]: from graph_tool.all import *
> Unable to init server: Could not connect: Connection refused
> Unable to init server: Could not connect: Connection refused
> In [2]: g = Graph()
> In [3]: v1 = g.add_vertex()
> In [4]: v2 = g.add_vertex()
> In [5]: e = g.add_edge(v1, v2)
> In [6]: graph_draw(g, vertex_text=g.vertex_index, vertex_font_size=18,
>...: output_size=(200, 200), output="two-nodes.png")
> Out[6]:  'vector', for Graph 0x7f60e1fbadd8, at 0x7f60e1fbcd68>
> 
> Do I make any obvious mistake?

I don't see any problems. The "Unable to init server" are only warnings,
meaning that a connection with the X server could not have been established.
This can be safely ignored.

-- 
Tiago de Paula Peixoto 



signature.asc
Description: OpenPGP digital signature
___
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool


Re: [graph-tool] Getting negative entropy/positive Log likelihood for a weighted network with positive edge weights.

2019-01-10 Thread Tiago de Paula Peixoto
Am 10.01.19 um 04:27 schrieb isukritgupta:
> Dear Tiago, I am trying to model a weighted dense network with edge weights
> in the range 0 to 1, with the non-hierarchical SBM for both degree corrected
> and non-degree corrected versions. However, I get negative entropy for both
> dc and ndc SBMs. I have attached a sample network for your consideration
> along with a minimal working example from my code. Thanks for your time!

When using real edge covariates, the overall likelihood becomes a
probability *density*. Since the probability density can exceed 1 in value,
its log can be positive, and hence the entropy can be negative. This is normal.

-- 
Tiago de Paula Peixoto 
___
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool