Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

[98] possible bug in graph_from_adjacency_matrix #35

Open
prmtl opened this issue Mar 8, 2015 · 0 comments
Open

[98] possible bug in graph_from_adjacency_matrix #35

prmtl opened this issue Mar 8, 2015 · 0 comments

Comments

@prmtl
Copy link
Contributor

prmtl commented Mar 8, 2015

Reported by giampisa...@gmail.com, 2015-01-26T13:22:22Z

Hi
in the function graph_from_adjacency_matrix, in order to define edges, a string is concatenated with an integer, which generates an error:

  Edge( node_prefix + node_orig, 
        node_prefix + node_dest) )

(node_prefix is a string, node_orig and node_dest are integers).

This is how you can reproduce the problem:

  1. define an adjacency matrix:
import numpy as np
am = np.array([[0, 1, 0], [1, 0, 0], [0, 1, 1]])
  1. run the function:
import pydot
bdot = pydot.graph_from_adjacency_matrix(am, directed=True)

The expected output is to obtain a bdot object, instead you get:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/pydot.py", line 302, in graph_from_adjacency_matrix
    Edge( node_prefix + node_orig, 
TypeError: coercing to Unicode: need string or buffer, int found

Similarly, if you run

bdot = pydot.graph_from_adjacency_matrix(np.asarray(a), node_prefix='', directed=True)

to avoid eventual problems with unicode, you get:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/pydot.py", line 302, in graph_from_adjacency_matrix
    Edge( node_prefix + node_orig, 
TypeError: cannot concatenate 'str' and 'int' objects

I am using Python 2.7.6, pydot version 1.0.28, on Ubuntu 14.04, 64 bits.
From: https://code.google.com/p/pydot/issues/detail?id=98

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

No branches or pull requests

1 participant