ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 27 Dec 2020 00:28:53 +0100Graphs on 6 vertices with eigenvalue conditionhttps://ask.sagemath.org/question/54878/graphs-on-6-vertices-with-eigenvalue-condition/Consider the class of all possible connected simple graphs on $6$ vertices. Now from this collection, can we find those graphs (if there exists any) satisfying the following property: Suppose that $A$ denotes the usual $(0,1)$ adjacency matrix of a graph. Now can we find those graphs explicitly (if there is any) on $6$ vertices such that if $\lambda$ is an eigenvalue of $A$, then $\dfrac{1}{\lambda}$ and $-\dfrac{1}{\lambda}$ both are eigenvalues. Simply the question can be said as: Characterize all possible simple connected graphs on $6$ vertices such that if $\lambda$ is an eigenvalue of $A$, then $\dfrac{1}{\lambda}$ and $-\dfrac{1}{\lambda}$ both are eigenvalues.
please help regarding this problem.Wed, 23 Dec 2020 22:25:05 +0100https://ask.sagemath.org/question/54878/graphs-on-6-vertices-with-eigenvalue-condition/Comment by slelievre for <p>Consider the class of all possible connected simple graphs on $6$ vertices. Now from this collection, can we find those graphs (if there exists any) satisfying the following property: Suppose that $A$ denotes the usual $(0,1)$ adjacency matrix of a graph. Now can we find those graphs explicitly (if there is any) on $6$ vertices such that if $\lambda$ is an eigenvalue of $A$, then $\dfrac{1}{\lambda}$ and $-\dfrac{1}{\lambda}$ both are eigenvalues. Simply the question can be said as: Characterize all possible simple connected graphs on $6$ vertices such that if $\lambda$ is an eigenvalue of $A$, then $\dfrac{1}{\lambda}$ and $-\dfrac{1}{\lambda}$ both are eigenvalues.</p>
<p>please help regarding this problem.</p>
https://ask.sagemath.org/question/54878/graphs-on-6-vertices-with-eigenvalue-condition/?comment=54937#post-id-54937Follow-up question at [Ask Sage question 54927](https://ask.sagemath.org/question/54927).Sun, 27 Dec 2020 00:28:53 +0100https://ask.sagemath.org/question/54878/graphs-on-6-vertices-with-eigenvalue-condition/?comment=54937#post-id-54937Answer by slelievre for <p>Consider the class of all possible connected simple graphs on $6$ vertices. Now from this collection, can we find those graphs (if there exists any) satisfying the following property: Suppose that $A$ denotes the usual $(0,1)$ adjacency matrix of a graph. Now can we find those graphs explicitly (if there is any) on $6$ vertices such that if $\lambda$ is an eigenvalue of $A$, then $\dfrac{1}{\lambda}$ and $-\dfrac{1}{\lambda}$ both are eigenvalues. Simply the question can be said as: Characterize all possible simple connected graphs on $6$ vertices such that if $\lambda$ is an eigenvalue of $A$, then $\dfrac{1}{\lambda}$ and $-\dfrac{1}{\lambda}$ both are eigenvalues.</p>
<p>please help regarding this problem.</p>
https://ask.sagemath.org/question/54878/graphs-on-6-vertices-with-eigenvalue-condition/?answer=54879#post-id-54879## Graphs on 6 vertices with eigenvalue condition
SageMath can call Nauty for enumerating graphs up to isomorphism.
This is done via the `graphs.nauty_geng` command.
Then one can filter by checking the conditions in the question
(which amount to the set of eigenvalues avoiding zero and
being stable by opposite and by inverse).
Define the requested list using `nauty_geng` and list comprehension.
sage: gg = [g for g in graphs.nauty_geng("6")
....: if all(e and -e in ee and 1/e in ee
....: for ee in [g.adjacency_matrix().eigenvalues()]
....: for e in ee)]
Some graphics options and positioning for plotting:
sage: pos = dict(enumerate([(2, 1), (0, 2), (2, 0), (1, 1), (3, 2), (1, 0)]))
sage: opt = {'xmin': -0.5, 'xmax': 3.5, 'ymin': -0.5, 'ymax': 2.5}
The four graphs:
sage: p = graphics_array([g.plot(pos=pos, **opt) for g in gg], ncols=2)
sage: p.show(figsize=4)
![Graphs on 6 vertices with eigenvalue condition](/upfiles/16087713668000958.png)
To save the picture to a file:
sage: filename = "ask-54878-graphs-n6-eigencondition.png"
sage: p.save(filename, transparent=True, figsize=4)
To request connectedness, call `nauty_geng("6 -c")` instead of `nauty_geng("6")`.Thu, 24 Dec 2020 01:57:44 +0100https://ask.sagemath.org/question/54878/graphs-on-6-vertices-with-eigenvalue-condition/?answer=54879#post-id-54879Comment by rewi for <h2>Graphs on 6 vertices with eigenvalue condition</h2>
<p>SageMath can call Nauty for enumerating graphs up to isomorphism.</p>
<p>This is done via the <code>graphs.nauty_geng</code> command.</p>
<p>Then one can filter by checking the conditions in the question
(which amount to the set of eigenvalues avoiding zero and
being stable by opposite and by inverse).</p>
<p>Define the requested list using <code>nauty_geng</code> and list comprehension.</p>
<pre><code>sage: gg = [g for g in graphs.nauty_geng("6")
....: if all(e and -e in ee and 1/e in ee
....: for ee in [g.adjacency_matrix().eigenvalues()]
....: for e in ee)]
</code></pre>
<p>Some graphics options and positioning for plotting:</p>
<pre><code>sage: pos = dict(enumerate([(2, 1), (0, 2), (2, 0), (1, 1), (3, 2), (1, 0)]))
sage: opt = {'xmin': -0.5, 'xmax': 3.5, 'ymin': -0.5, 'ymax': 2.5}
</code></pre>
<p>The four graphs:</p>
<pre><code>sage: p = graphics_array([g.plot(pos=pos, **opt) for g in gg], ncols=2)
sage: p.show(figsize=4)
</code></pre>
<p><img alt="Graphs on 6 vertices with eigenvalue condition" src="/upfiles/16087713668000958.png"></p>
<p>To save the picture to a file:</p>
<pre><code>sage: filename = "ask-54878-graphs-n6-eigencondition.png"
sage: p.save(filename, transparent=True, figsize=4)
</code></pre>
<p>To request connectedness, call <code>nauty_geng("6 -c")</code> instead of <code>nauty_geng("6")</code>.</p>
https://ask.sagemath.org/question/54878/graphs-on-6-vertices-with-eigenvalue-condition/?comment=54883#post-id-54883This is a very nice answer. Thank youThu, 24 Dec 2020 17:10:25 +0100https://ask.sagemath.org/question/54878/graphs-on-6-vertices-with-eigenvalue-condition/?comment=54883#post-id-54883