Re: [graph-tool] TypeError while using add_edge_list

2018-07-18 Thread ashutosh
I got the problem.

Graph Tool by default accepts only vertex objects or int(index) values on
edge list and hence either I pass on vertex object list or keep the options*
hashed=True and string_vals=True* in the add_edge_list option.

The problem is resolved now. Thank you



--
Sent from: 
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/
___
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool


Re: [graph-tool] TypeError while using add_edge_list

2018-07-18 Thread ashutosh
sampleFile.tab

  

above is the sample file.

and below is the code that produces the error as i mentioned before

import pandas as pd
import graph_tool.all as gtx
df = pd.read_csv("file_path",sep='\t',headers=True)

myGraph = gtx.Graph()

myGraph.add_edge_list(df.values.tolist())



--
Sent from: 
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/
___
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool


Re: [graph-tool] TypeError while using add_edge_list

2018-07-18 Thread Alexandre Hannud Abdo
Tiny typo, the first argument is `hashed=True`.

On Wed, Jul 18, 2018 at 1:18 PM, Alexandre Hannud Abdo 
wrote:

> Ni! Hi ashu,
>
> Please, always try to *read errors carefully* and consult the
> documentation. Not to mention, provide self-contained examples.
>
> Python is throwing a "TypeError" and telling you it expects an integer
> ('unsigned long', the C++ type for vertex indices) while you are passing it
> a string ('str').
>
> As you can see in the documentation
> , if you want to
> pass strings to add_edge_list you should set two additional arguments:
> `hash=True` and `string_vals=True`.
>
> If that doesn't fix it, you'll have to provide a self-contained example
> where the error occurs, otherwise we can't really help.
>
> .~´
>
>
>
> On Wed, Jul 18, 2018 at 9:37 AM, ashutosh  wrote:
>
>> Hi,
>>
>> I'm trying to convert two columns of my pandas dataframe into network
>> using
>> them as edge list.
>> A  similar query
>> > ding-edge-lists-from-pandas-dataframe>
>> was posted in StackOverflow but with different problem and it didn't help
>> me.
>>
>> When I am trying the following code it gives me error:
>> *
>> myGraph.add_edge_list(i for i in df[['node1','node2']].values.tolist())*
>>
>> Where, my Graph is the graph;  df is the dataframe with 4 columns out of
>> which I am using two 'node1' and 'node2'.
>>
>> *File "/usr/lib/python3/dist-packages/graph_tool/__init__.py", line
>> 2109, in
>> add_edge_list
>> libcore.add_edge_list_iter(self.__graph, edge_list, eprops)*
>>
>> *TypeError: No registered converter was able to produce a C++ rvalue of
>> type
>> unsigned long from this Python object of type str
>> *
>>
>>
>> I tried upgrading my boost library but it doesn't solve the problem. Any
>> suggestions ?
>>
>>
>>
>> --
>> Sent from: http://main-discussion-list-for-the-graph-tool-project.98248
>> 0.n3.nabble.com/
>> ___
>> graph-tool mailing list
>> graph-tool@skewed.de
>> https://lists.skewed.de/mailman/listinfo/graph-tool
>>
>
>
___
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool


Re: [graph-tool] TypeError while using add_edge_list

2018-07-18 Thread Alexandre Hannud Abdo
Ni! Hi ashu,

Please, always try to *read errors carefully* and consult the
documentation. Not to mention, provide self-contained examples.

Python is throwing a "TypeError" and telling you it expects an integer
('unsigned long', the C++ type for vertex indices) while you are passing it
a string ('str').

As you can see in the documentation
, if you want to
pass strings to add_edge_list you should set two additional arguments:
`hash=True` and `string_vals=True`.

If that doesn't fix it, you'll have to provide a self-contained example
where the error occurs, otherwise we can't really help.

.~´



On Wed, Jul 18, 2018 at 9:37 AM, ashutosh  wrote:

> Hi,
>
> I'm trying to convert two columns of my pandas dataframe into network using
> them as edge list.
> A  similar query
>  reading-edge-lists-from-pandas-dataframe>
> was posted in StackOverflow but with different problem and it didn't help
> me.
>
> When I am trying the following code it gives me error:
> *
> myGraph.add_edge_list(i for i in df[['node1','node2']].values.tolist())*
>
> Where, my Graph is the graph;  df is the dataframe with 4 columns out of
> which I am using two 'node1' and 'node2'.
>
> *File "/usr/lib/python3/dist-packages/graph_tool/__init__.py", line 2109,
> in
> add_edge_list
> libcore.add_edge_list_iter(self.__graph, edge_list, eprops)*
>
> *TypeError: No registered converter was able to produce a C++ rvalue of
> type
> unsigned long from this Python object of type str
> *
>
>
> I tried upgrading my boost library but it doesn't solve the problem. Any
> suggestions ?
>
>
>
> --
> Sent from: http://main-discussion-list-for-the-graph-tool-project.
> 982480.n3.nabble.com/
> ___
> graph-tool mailing list
> graph-tool@skewed.de
> https://lists.skewed.de/mailman/listinfo/graph-tool
>
___
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool


Re: [graph-tool] Using an edge covariate as a hyper parameter for the SBM

2018-07-18 Thread Tiago de Paula Peixoto
Am 16.07.2018 um 22:46 schrieb Zahra Sheikhbahaee:
> Hi Tiago,
> 
> Thanks for the explanation. I have another question:
> 
> In the "Inferring the mesoscale structure of layered, edge-valued and
> time-varying networks", you compared two way of constructing layered
> structures: first approach: You assumed an adjacency matrix in each
> independent layer. The second method, the collapsed graph considered as a
> result of merging all the adjacency matrices together.
> 
> I am wondering how I can use graph_tool for the first method? Which method
> or class should I use?

You have to pass the option "layers=True" to the LayeredBlockState constructor:

https://graph-tool.skewed.de/static/doc/inference.html#graph_tool.inference.layered_blockmodel.LayeredBlockState

> If there is a class, is it still possible to consider
> a graph with weighted edges?

Yes, it accepts 'recs/rec_types/rec_params' just like the regular BlockState.

Best,
Tiago

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


[graph-tool] TypeError while using add_edge_list

2018-07-18 Thread ashutosh
Hi,

I'm trying to convert two columns of my pandas dataframe into network using
them as edge list.
A  similar query

  
was posted in StackOverflow but with different problem and it didn't help
me.

When I am trying the following code it gives me error:
*
myGraph.add_edge_list(i for i in df[['node1','node2']].values.tolist())*

Where, my Graph is the graph;  df is the dataframe with 4 columns out of
which I am using two 'node1' and 'node2'.

*File "/usr/lib/python3/dist-packages/graph_tool/__init__.py", line 2109, in
add_edge_list
libcore.add_edge_list_iter(self.__graph, edge_list, eprops)*

*TypeError: No registered converter was able to produce a C++ rvalue of type
unsigned long from this Python object of type str
*


I tried upgrading my boost library but it doesn't solve the problem. Any
suggestions ?



--
Sent from: 
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/
___
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool