I'd like to use GraphData
to get a list of graphs with vertex connectivity at least 3. I know GraphData["Nonplanar", 6]
gives all the nonplanar graphs on 6 vertices, but I can't figure out how to get GraphData
to do a selection based on the "VertexConnectivity"
property.
1 Answer
It's been suggested that I combine the helpful information given in comments into an answer. To deal with the original question (restricting the list of graphs based on "VertexConnectivity"
), use Select
:
Select[GraphData[], (GraphData[#, "VertexConnectivity"] >= 3) &]
However, this particular property apparently has some bugs, detailed at "Is there something wrong with VertexConnectivity". To be safe, we can use the function from Combinatorica, like so.
Block[{$ContextPath},
Needs["Combinatorica`"];
Needs["GraphUtilities`"]
]
Select[GraphData[],
(Combinatorica`VertexConnectivity[
GraphUtilities`ToCombinatoricaGraph[GraphData[#]]] >= 3) &]
This issue did not arise for me.
To combine multiple such conditions, use &&
between separate calls to GraphData
, for instance:
Select[GraphData[], (GraphData[#, "EdgeChromaticNumber"] == 3 && GraphData[#, "VertexConnectivity"] >= 3) &]
All of these commands will take a very long time. It helps somewhat to preload all the information, getting all the downloads over with, which you can accomplish with GraphData[All, "Preload"]
. But it still takes a long time to run. Restricting to graphs of a certain size makes it much quicker. To restrict to graphs on 7 vertices:
Select[GraphData[7], (GraphData[#, "EdgeChromaticNumber"] == 3 && GraphData[#, "VertexConnectivity"] >= 3) &]
You can also restrict this way based on the boolean properties, which GraphData
can already do itself, as with "Nonplanar"
in the question. Multiple ones may be combined like this:
Select[GraphData[{"Nonhamiltonian", "Nonplanar", "Connected"}, 7], (GraphData[#, "ChromaticNumber"] == 3) &]
-
$\begingroup$ Nicely done.$\phantom{}$ $\endgroup$ Commented Apr 21, 2013 at 14:04
Select[GraphData[], (GraphData[#, "VertexConnectivity"] >= 3) &]
$\endgroup$GraphData[6]
in the first part of J.M.'s command) so the download's not so bad. $\endgroup$Select[GraphData[{"Nonhamiltonian", "Nonplanar", "Connected"}, 7], (GraphData[#, "EdgeChromaticNumber"] == 3 && GraphData[#, "VertexConnectivity"] >= 3) &]
. Is this correct? Would it be more efficient to somehow combine the two calls to GraphData in the condition, and is this even possible? $\endgroup$