Ok, my own mistake. The problem is that V (the set of sets) needs to
be turned into a list. This works for me now:
X = Set([1,2,3,4,5])
V = list(X.subsets(2))
def s(a,b):
return a.intersection(b).cardinality()==0
T = Graph([V, s])
Hope that helps
Cheers
Javier
On Jul 16, 5:26 pm, javier <[email protected]> wrote:
> You need to define a function on pair of vertices that returns "True"
> if there should be an edge.
>
> Something like
>
> X = Set([1,2,3,4,5])
> V=(X.subsets(2))
>
> def s(a,b):
> return a.intersection(b).cardinality()==0
>
> T = Graph([V, s])
>
> should work, but I am getting the following weird error in sage 4.1:
>
> ---------------------------------------------------------------------------
> AttributeError Traceback (most recent call
> last)
>
> /home/network/jlopez/.sage/temp/mrcpc10.maths.qmul.ac.uk/4734/
> _home_network_jlopez__sage_init_sage_0.py in <module>()
>
> /scratch/sage/local/lib/python2.6/site-packages/sage/graphs/graph.pyc
> in __init__(self, data, pos, loops, format, boundary, weighted,
> implementation, sparse, vertex_labels, **kwds)
> 8863 if multiedges is None: multiedges = False
> 8864 if weighted is None: weighted = False
> -> 8865 num_verts = len(data[0])
> 8866 verts = data[0]
> 8867 elif format == 'dict_of_dicts':
>
> /scratch/sage/local/lib/python2.6/site-packages/sage/combinat/
> combinat.pyc in __len__(self)
> 841 AttributeError: __len__ has been removed;
> use .cardinality() instead
> 842 """
> --> 843 raise AttributeError, "__len__ has been removed;
> use .cardinality() instead"
> 844
> 845 def count(self):
>
> AttributeError: __len__ has been removed; use .cardinality() instead
>
> Is that a bug or did I do something wrong?
>
> Cheers
> Javier
>
> On Jul 16, 4:52 pm, Taxman <[email protected]> wrote:
>
> > Hi, I'm trying to construct an odd graph (http://en.wikipedia.org/wiki/
> > Odd_graph).
> > My first thought was to use
> > X = Set([1,2,3,4,5])
> > V=(X.subsets(2))
> > to get the desired subsets for the vertex set. That does get the
> > subsets, but converting it into a graph doesn't seem to work.
> > T=Graph(V) gives:
> > networkx.exception.NetworkXError: Input is not a known data type for
> > conversion.
>
> > The next step in constructing the graph is to create edges wherever
> > the subsets of the corresponding vertices are disjoint. I didn't know
> > how to go about that.
>
> > Any ideas?
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---