Dear Tiago,
I have a directed graph of about half a million nodes and approximately a
million edges following scale free behaviour and a power law degree
distribution. To test some of my hypothesis, I would like to generate random
smaller graphs (about 50 up to 200 nodes) representative of the big one.
When I used a sample function that samples straight away from the real
distribution of the big network, I have following problems:
- I generate unconnected nodes with both 0 in AND out degree.
- I generate small sub parts of a few nodes that are not connected to the
main graph.
- If only sampling from nodes with at least 1 degree, the generated graph is
coherent, but not representative anymore as I need a big portion of nodes
with either only one in or one out degree.
Here is the part of my script I used for that, where samples are drawn from
dictionaries of the degrees:
def sample_in():
a=np.random.randint(num)
k_in = in_degrees[a]
return k_in
def sample_out():
if sample_in()==0:
b=np.random.randint(num_out)
k_out=out_zero_zeros.values()[b]
return k_out
else:
b=np.random.randint(num)
k_out=out_degrees[b]
return k_out
N=200
g=gt.random_graph(N, lambda:(sample_in(), sample_out()),
model="constrained-configuration", directed=True)
I also tried sampling from a list of tuples as you have mentioned before in
the forum, but I didn't receive any results, as the tuples randomly drawn
from my list might not be combinable.
degs=[(7,1),(4,3),(5,6),(2,4),(6,8),(2,0),(3,5),(0,3),(2,7),(2,1)]
g = gt.random_graph(4, lambda i: degs[i], directed=True)
- Is there any option I could active that would help me in those cases I
described above?
- Is there a better way how to create representative small networks?
Any help on that issue will be much appreciated.
Best wishes,
Jana
--
Sent from: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/

I am curious what is being used to calculate the standard deviation of the
average in gt.vertex_average and gt.edge_average
>>> t2=gt.Graph()
>>> t2.add_vertex(2)
>>> t2.add_edge(t2.vertex(0), t2.vertex(1))
>>> gt.vertex_average(t2, "in")
(0.5, 0.35355339059327373)
Now, shouldn't std be σ(n)=sqrt(((0-0.5)^2+(1-0.5)^2)/2)=0.5 ?
also q(n-1)=sqrt((0.5^2+0.5^2)/(2-1))~=0.70710
0.3535 is sqrt(2)/4 which happens to be σ(n-1)/2, so it seems there is some
relation to that.
A little bigger graph.
>>> t3=gt.Graph()
>>> t3.add_vertex(5)
>>> t3.add_edge(t3.vertex(0), t3.vertex(1))
>>> gt.vertex_average(t3, "in")
(0.2, 0.17888543819998318)
Now, we should have 0,1,0,0,0 series for vertex incoming degree.
So Windows calc gives σ(n)=0.4 and σ(n-1)~=0.44721, so where does 0.1788854
come from ?
Reason, I am asking because, I have a large graph, where the average looks
quite alright but the std makes no sense, as going by the histogram, degree
values are quite a bit more distributed than the std would indicate.
--
View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com…
Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.

Hi,
I was wondering if there is any way to assign vertex properties while
adding edges to the graph. for example using "add_edge_list" I can assign
edge properties but later I have to iterate through all vertices again to
assign their properties.
I know this is not a problem when the vertex property is of the type "int"
or "float" because then one can use "vprop.a = values", but in case of
"string" and "object" this method doesn't work
What would be the best/fastest way to handle this situation.
I guess it would be very helpful to extend the "add_edge_list" function to
accept vertex property in some way.
cheers,
--
Mohsen

I ran mcmc_equilibrate on a nested block state model in a weighted graph. As
per instructions, I copied the initially computed state in another object
with increased hierarchy depth to 10. However, this fixed the depth to 10.
Everything computed afterwards has depth 10 even if is clear that after 3 or
4 levels the nodes converge to one.
There are many empty branches and when I try to plot it with empty_branches
= False, I get an error stating it is not a tree.
RuntimeError: Invalid hierarchical tree: No path from source to target.
Did anybody perform any similar analyses?
The hierarchy after mcmc_equilibrate:
<NestedBlockState object, with base <BlockState object with 24 blocks (24
nonempty), degree-corrected, with 1 edge covariate, for graph <Graph
object, undirected, with 230 vertices and 11230 edges, edges filtered by
(<PropertyMap object with key type 'Edge' and value type 'bool', for
Graph 0x7fc3a89f1210, at 0x7fc3a64911d0>, False), vertices filtered by
(<PropertyMap object with key type 'Vertex' and value type 'bool', for Graph
0x7fc3a89f1210, at 0x7fc3a64912d0>, False) at 0x7fc3a89f1210>, at
0x7fc3a6491950>, and 10 levels of sizes [(230, 24), (24, 5), (5, 1), (1, 1),
(1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1)] at 0x7fc3a6491590>
--
Sent from: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/

Dear all,
I am a bit confused about the use of the weighted network models for a
weight prediction task;
Suppose we have a weighted network where edges are integers. We fit a
SBM with a Poisson kernel as follows:
|data = gt.load_graph(...) # The adjacency matrix has integer entries,
and weights greater than zero are stored in data.ep.weights. state =
gt.inference.minimize_blockmodel(data, B_min=10, B_max=10, state_args=
{'recs':[data.ep.weights], 'rec_types' : ["discrete-poisson"]}) |
My question, is how can we obtain, from |state|, a point estimate of the
Poisson parameters in order to compute the distribution of the weights
between pairs of nodes.
Regards,
Adrien Dulac

Sir,
Is there any way to enforce two nodes to be present in different network
partitions rather than allowing the SBM algorithm itself to figure
partitions for every node ?
A little different question to the above would be, is it possible to allow
partitions around specific nodes only in graph tool ?
For the first one, there is an option to define the initial state in SBM
algorithm, but I think that requires to define for every node. Also after
the algorithm runs the network will eventually converge towards best
partition which may or may not respect the condition of keeping two nodes
separate.
For the second, I feel it becomes like a k-means clustering.
--
Sent from: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/

Greetings!
I recently built graph-tool for Oracle Linux and it seems to work fine (at
least simple test passes).
The problem Im trying to solve is to use graph-tool with Conda (or
virtualenv). The build I did makes an RPM package that installs to the
system directory.
So, the question is: is there a way to relocate graph-tool module to
another directory except completely rebuilding it?
Of course I can solve Conda problem by either setting PYTHONPATH or by
symlinking the module to Conda environment (or even by building Conda
package), but it doesnt look right for me.
Thank you!

HI I am new to graph tools, and I have installed graph tools in anaconda
environment on my PC(CentOS 7) and tried to run the following example code:
*>>>from graph_tool.all import *>>>g = Graph()>>>v1 = g.add_vertex()>>>v2 =
g.add_vertex()>>>e = g.add_edge(v1,
v2)>>>graph_tool.draw.graph_draw(g, **vertex_text=g.vertex_index,
vertex_font_size=18,output_size=(200, 200), output="two-nodes.png")*
and I get his error
/home/maddy/anaconda2/bin/python: symbol lookup error:
/home/maddy/anaconda2/lib/python2.7/site-packages/graph_tool/draw/libgraph_tool_draw.so:
undefined symbol:
_ZN5Cairo7Context16select_font_faceERKSsNS_9FontSlantENS_10FontWeightE
however i don't get the error if i don't use:
*vertex_text=g.vertex_index in graph_draw*
and the code successfully gives expected graph except for vertex_index
Work-around:
Although I found from the forums that It could be due to LD_LIBRARY_PATH
and I have set the path in ~/.bashrc:
*export LD_LIBRARY_PATH:"/home/maddy/anaconda2/lib:$LD_LIBRARY_PATH"*
Could you you help me fix the issue as I am in dire need to generate the
graphs for academic purposes and deadlines are just around.
Thank you for the patience
Madhav

Any idea what I'm doing wrong? I"m running Centos7.5 gcc version 7.3.1
20180303, Python 3.6.3
and even though i've included the cgal directory in the command it can't
find it. I get the error below :
checking for exit in -lboost_thread... yes
checking for __gmpz_init in -lgmp... yes
checking for __gmpz_init in -lgmp... (cached) yes
checking whether CGAL is available in /MYINSTALL/release/cgal4.10... no
checking whether CGAL is available in /usr... no
checking whether CGAL is available in /usr/local... no
checking whether CGAL is available in /opt... no
checking whether CGAL is available in /opt/local... no
configure: error: CGAL library not found.
The command I'm running is:
./configure --disable-cairo --disable-sparsehash
--prefix="/MYINSTALL/graphtool2.27" --with-boost="/MYINSTALL/boost1.61/"
CGAL_HOME="/MYINSTALL/cgal4.10/" CGAL_LDFLAGS="-L/MYINSTALL/cgal4.10/lib64/
-lCGAL -lCGAL_Core -lgmp -lboost_thread -lpthread"
LDFLAGS="-L/MYINSTALL/cgal4.10/lib64/
-Wl,-rpath-link,/MYINSTALL/boost1.61/lib" --with-cgal="/MYINSTALL/cgal4.10"
What I see in the logs are :
configure:21200: checking whether CGAL is available in /MYINSTALL/cgal4.10
configure:21236: g++ -o conftest -fopenmp -O3 -fvisibility=default
-fvisibility-inlines-hidden -Wno-deprecated -Wall -Wextra
-ftemplate-backtrace-limit=0 -DNDEBUG -I/MYINSTALL/cgal4.10/include
-pthread -I/MYINSTALL/boost1.61//include -L/MYINSTALL/cgal4.10/lib64/
-Wl,-rpath,/MYINSTALL/cgal4.10/lib64
-Wl,-rpath-link,/MYINSTALL/boost1.61/lib -L/MYINSTALL/cgal4.10/lib -lCGAL
-lCGAL_Core -lgmp -lboost_thread -lpthread conftest.cpp -lgmp -lgmp >&5
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: cannot
find -lboost_thread
collect2: error: ld returned 1 exit status
configure:21236: $? = 1
configure: program exited with status 1
--
Sent from: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/