# How do I add an attribute to the object/class "Graph?"

Hi,

I am researching methods that relate to graph minors. Currently I am looking at creating a method/function/attribute (I give the options as I do not know the best means, . . . , yet) which will allow me to test for forbidden minors.

An example is the complete graph on 6 vertices is a forbidden minor for the class of graphs that are not apex. Meaning, that given a graph G and a $v\in V(G)$, that $G-v$ is not planar. So the code that I have been working on should test if a graph matches a certain criteria. I would be able to ask SageMath in the following way

```
K6=graphs.CompleteGraph(6); K6.is_apex()
```

Of which the response would be

```
False
```

This is the code that I have been working on

```
def is_apex(g):
for v in g.vertex_iterator():
l = g.neighbors(v)
g.delete_vertex(v)
if g.is_planar():
return True
g.add_vertex(v)
g.add_edges([(v, y) for y in l])
return False
```

Now I had help on this from another member in the AskSage community, so thank you.

But now I am trying to do something like this:

```
class Graph():
not_apex = False
def is_apex(self):
for v in self.vertex_iterator():
l = self.neighbors(v)
g.delete_vertex(v)
if self.is_planar():
return True
self.add_vertex(v)
self.add_edges([(v, y) for y in l])
return False
```

Which when I enter

```
x.is_apex()
```

Of which the response that I get

```
---------------------------------------------------------------------------
```

AttributeError Traceback (most recent call last) <ipython-input-15-e74e0334c694> in <module>() ----> 1 x.is_apex()

AttributeError: 'Graph' object has no attribute 'is_apex'

I am still a nooooooooob, so any help in understanding what I need to do would be great.

Thank you

Hi, could you edit your question and apply "code formatting" to the error message too? (Just so it displays nicely.) Thanks!