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

gravis is not working with a subclass derived from a valid graph #8

Open
lnajman opened this issue Feb 11, 2023 · 1 comment
Open

Comments

@lnajman
Copy link

lnajman commented Feb 11, 2023

Here is a minimal example:

The following is working:

import igraph as ig
import gravis as gv

lnames = ['0', '1']
edgelist = [('0', '1')]
graph = ig.Graph(len(lnames),  vertex_attrs={'name': lnames})
graph.add_edges(edgelist)
gv.vis(graph)

The following is not:

class mygraph(ig.Graph):
  def __init__(self, lnames, edgelist):
    super().__init__(len(lnames), vertex_attrs={'name': lnames})
    self.add_edges(edgelist)

graph = mygraph(lnames, edgelist)
gv.vis(graph)

This returns

ValueError: The provided data seems not to be in a valid graph format.

Is there a workaround?

@lnajman
Copy link
Author

lnajman commented Feb 11, 2023

A ugly workaround is

graph = mygraph(lnames, edgelist)
print(graph.__class__)
graph.__class__ = ig.Graph
gv.vis(graph)

But this is really ugly.

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

No branches or pull requests

1 participant