Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save_state_file prints the full information of nodes #54

Open
giava90 opened this issue Apr 20, 2018 · 2 comments
Open

save_state_file prints the full information of nodes #54

giava90 opened this issue Apr 20, 2018 · 2 comments
Assignees
Labels

Comments

@giava90
Copy link
Member

giava90 commented Apr 20, 2018

It creates a file where after the #Vertices , it writes each node with all its properties, e.g.

*Vertices 5
0 "{'inweight': array([ 0.,  0.]), 'outweight': array([ 5.,  2.]), 'indegree': 0, 'outdegree': 1}"
1 "{'inweight': array([ 11.,   3.]), 'outweight': array([ 11.,   5.]), 'indegree': 2, 'outdegree': 2}"
2 "{'inweight': array([ 0.,  0.]), 'outweight': array([ 6.,  1.]), 'indegree': 0, 'outdegree': 1}"
3 "{'inweight': array([ 5.,  3.]), 'outweight': array([ 0.,  0.]), 'indegree': 1, 'outdegree': 0}"
4 "{'inweight': array([ 6.,  2.]), 'outweight': array([ 0.,  0.]), 'indegree': 1, 'outdegree': 0}"

Instead, we usually need only its name (at least when using this .net files for infomap), e.g.

0  "1"
1 "2"
2 "3"
3 "4"
4 "5"
@giava90
Copy link
Member Author

giava90 commented Apr 20, 2018

I have looked into the code and this is what I have understood/suggest.
This happens because the loop that prints the vertices is:

first_layer_map = self.layers[1].node_to_name_map()
.
.
for i in self.layers[1].nodes:
                first = first_layer_map[i]
                second = self.layers[1].nodes[i]
                file.write('{0} "{1}"\n'.format(first, second))

I suggest to use:

first_layer_map = self.layers[1].node_to_name_map()
.
.
for name, index,  in first_layer_map.items():
    file.write('{0} "{1}"\n'.format(index+1, name))

edit: We need the index+1 in the write as Infomap do not like indexes starting from 0.

@IngoScholtes
Copy link
Collaborator

Kamino cloned this issue to uzhdag/pathpy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants