Graph database¶
This module implements classes (GraphDatabase
, GraphQuery
,
GenericGraphQuery
) for interfacing with the sqlite
database
graphs.db
.
The GraphDatabase
class interfaces with the sqlite
database
graphs.db
. It is an immutable database that inherits from
SQLDatabase
(see sage.databases.sql_db
).
The database contains all unlabeled graphs with 7 or fewer nodes. This class
will also interface with the optional database package containing all unlabeled
graphs with 8 or fewer nodes. The database(s) consists of five tables, and has
the structure given by the function graph_db_info()
(For a full
description including column data types, create a GraphDatabase
instance and call the method
get_skeleton()
).
AUTHORS:
Emily A. Kirkman (2008-09-20): first version of interactive queries, cleaned up code and generalized many elements to sage.databases.sql_db.py
Emily A. Kirkman (2007-07-23): inherits GenericSQLDatabase, also added classes: GraphQuery and GenericGraphQuery
Emily A. Kirkman (2007-05-11): initial sqlite version
Emily A. Kirkman (2007-02-13): initial version (non-sqlite)
REFERENCES:
Data provided by Jason Grout (Brigham Young University). [Online] Available: http://artsci.drake.edu/grout/graphs/
- class sage.graphs.graph_database.GenericGraphQuery(query_string, database=None, param_tuple=None)¶
Bases:
sage.databases.sql_db.SQLQuery
A query for a
GraphDatabase
.INPUT:
query_string
– a string representing the SQL querydatabase
– (default:None
); theGraphDatabase
instance to query (ifNone
then a new instance is created)param_tuple
– a tuple of strings (default:None
); what to replace question marks inquery_string
with (optional, but a good idea)
Note
This query class is generally intended for developers and more advanced users. It allows you to execute any query, and so may be considered unsafe.
EXAMPLES:
See
GraphDatabase
class docstrings or enter:sage: G = GraphDatabase() sage: G.get_skeleton() {...
to see the underlying structure of the database. Also see
sage.databases.sql_db.SQLQuery
insage.databases.sql_db
for more info and a tutorial.A piece of advice about ‘?’ and param_tuple: it is generally considered safer to query with a ‘?’ in place of each value parameter, and using a second argument (a tuple of strings) in a call to the
sqlite
database. Successful use of theparam_tuple
argument is exemplified:sage: G = GraphDatabase() sage: q = 'select graph_id,graph6,num_vertices,num_edges from graph_data where graph_id<=(?) and num_vertices=(?)' sage: param = (22,5) sage: Q = SQLQuery(G, q, param) sage: Q.show() graph_id graph6 num_vertices num_edges -------------------------------------------------------------------------------- 18 D?? 5 0 19 D?C 5 1 20 D?K 5 2 21 D@O 5 2 22 D?[ 5 3
- class sage.graphs.graph_database.GraphDatabase¶
Bases:
sage.databases.sql_db.SQLDatabase
Graph Database
This class interfaces with the
sqlite
databasegraphs.db
. It is an immutable database that inherits fromSQLDatabase
(seesage.databases.sql_db
). The display functions and get_graphs_list create their own queries, but it is also possible to query the database by constructing either aSQLQuery
.The database contains all unlabeled graphs with 7 or fewer nodes. This class will also interface with the optional database package containing all unlabeled graphs with 8 or fewer nodes. The database consists of five tables. For a full table and column structure, call
graph_db_info()
.The tables are associated by the unique primary key
graph_id
(int).To query this database, we create a
GraphQuery
. This can be done directly with thequery()
method or by initializing one of:GenericGraphQuery
– allows direct entry of a query string and tuple of parameters. This is the route for more advanced users that are familiar with SQLGraphQuery
– a wrapper of SQLQuery, a general database/query wrapper of SQLite for new users
REFERENCES:
Data provided by Jason Grout (Brigham Young University). [Online] Available: http://artsci.drake.edu/grout/graphs/
EXAMPLES:
sage: G = GraphDatabase() sage: G.get_skeleton() {u'aut_grp': {u'aut_grp_size': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'edge_transitive': {'index': True, 'primary_key': False, 'sql': u'BOOLEAN', 'unique': False}, u'graph_id': {'index': False, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'num_fixed_points': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'num_orbits': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'vertex_transitive': {'index': True, 'primary_key': False, 'sql': u'BOOLEAN', 'unique': False}}, u'degrees': {u'average_degree': {'index': True, 'primary_key': False, 'sql': u'REAL', 'unique': False}, u'degree_sequence': {'index': False, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'degrees_sd': {'index': True, 'primary_key': False, 'sql': u'REAL', 'unique': False}, u'graph_id': {'index': False, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'max_degree': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'min_degree': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'regular': {'index': True, 'primary_key': False, 'sql': u'BOOLEAN', 'unique': False}}, u'graph_data': {u'complement_graph6': {'index': True, 'primary_key': False, 'sql': u'TEXT', 'unique': False}, u'eulerian': {'index': True, 'primary_key': False, 'sql': u'BOOLEAN', 'unique': False}, u'graph6': {'index': True, 'primary_key': False, 'sql': u'TEXT', 'unique': False}, u'graph_id': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': True}, u'lovasz_number': {'index': True, 'primary_key': False, 'sql': u'REAL', 'unique': False}, u'num_cycles': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'num_edges': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'num_hamiltonian_cycles': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'num_vertices': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'perfect': {'index': True, 'primary_key': False, 'sql': u'BOOLEAN', 'unique': False}, u'planar': {'index': True, 'primary_key': False, 'sql': u'BOOLEAN', 'unique': False}}, u'misc': {u'clique_number': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'diameter': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'edge_connectivity': {'index': True, 'primary_key': False, 'sql': u'BOOLEAN', 'unique': False}, u'girth': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'graph_id': {'index': False, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'independence_number': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'induced_subgraphs': {'index': True, 'primary_key': False, 'sql': u'TEXT', 'unique': False}, u'min_vertex_cover_size': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'num_components': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'num_cut_vertices': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'num_spanning_trees': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'radius': {'index': True, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'vertex_connectivity': {'index': True, 'primary_key': False, 'sql': u'BOOLEAN', 'unique': False}}, u'spectrum': {u'eigenvalues_sd': {'index': True, 'primary_key': False, 'sql': u'REAL', 'unique': False}, u'energy': {'index': True, 'primary_key': False, 'sql': u'REAL', 'unique': False}, u'graph_id': {'index': False, 'primary_key': False, 'sql': u'INTEGER', 'unique': False}, u'max_eigenvalue': {'index': True, 'primary_key': False, 'sql': u'REAL', 'unique': False}, u'min_eigenvalue': {'index': True, 'primary_key': False, 'sql': u'REAL', 'unique': False}, u'spectrum': {'index': False, 'primary_key': False, 'sql': u'TEXT', 'unique': False}}}
- interactive_query(display_cols, **kwds)¶
Generate an interact shell to query the database.
This method generates an interact shell (in the notebook only) that allows the user to manipulate query parameters and see the updated results.
Todo
This function could use improvement. Add full options of typical
GraphQuery
(i.e.: have it accept list input); and update options in interact to make it less annoying to put in operators.EXAMPLES:
sage: D = GraphDatabase() sage: D.interactive_query(display_cols=['graph6', 'num_vertices', 'degree_sequence'], num_edges=5, max_degree=3) # py2 # optional -- sagenb <html>...</html>
Warning
Above doctest is known to fail with Python 3 due to
sagenb
. See trac ticket #27435 for more details.
- query(query_dict=None, display_cols=None, **kwds)¶
Create a GraphQuery on this database.
For full class details, type
GraphQuery?
and pressshift+enter
.EXAMPLES:
sage: D = GraphDatabase() sage: q = D.query(display_cols=['graph6', 'num_vertices', 'degree_sequence'], num_edges=['<=', 5]) sage: q.show() Graph6 Num Vertices Degree Sequence ------------------------------------------------------------ @ 1 [0] A? 2 [0, 0] A_ 2 [1, 1] B? 3 [0, 0, 0] BG 3 [0, 1, 1] BW 3 [1, 1, 2] Bw 3 [2, 2, 2] C? 4 [0, 0, 0, 0] C@ 4 [0, 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 1, 2, 2, 2, 2] F?C_w 7 [0, 0, 1, 2, 2, 2, 3] F?Ca? 7 [0, 1, 1, 1, 1, 1, 1] F?CaW 7 [0, 1, 1, 1, 2, 2, 3] F?Ch_ 7 [0, 0, 2, 2, 2, 2, 2] F?CqO 7 [0, 1, 1, 2, 2, 2, 2] F?LCG 7 [1, 1, 1, 1, 2, 2, 2] F@??W 7 [0, 0, 1, 1, 1, 1, 2] F@?GW 7 [0, 0, 1, 1, 2, 2, 2] FG??w 7 [0, 1, 1, 1, 1, 1, 3] FG?Gg 7 [0, 1, 1, 1, 1, 2, 2] FG?Gw 7 [0, 1, 1, 1, 2, 2, 3] FG?Wo 7 [0, 1, 1, 2, 2, 2, 2] FK??W 7 [1, 1, 1, 1, 1, 1, 2] FK?GW 7 [1, 1, 1, 1, 2, 2, 2] F_?@w 7 [1, 1, 1, 1, 1, 1, 4] F_?Hg 7 [1, 1, 1, 1, 1, 2, 3] F_?XO 7 [1, 1, 1, 1, 2, 2, 2]
- class sage.graphs.graph_database.GraphQuery(graph_db=None, query_dict=None, display_cols=None, **kwds)¶
Bases:
sage.graphs.graph_database.GenericGraphQuery
A query for an instance of
GraphDatabase
.This class nicely wraps the
sage.databases.sql_db.SQLQuery
class located insage.databases.sql_db
to make the query constraints intuitive and with as many pre-definitions as possible. (i.e.: since it has to be aGraphDatabase
, we already know the table structure and types; and since it is immutable, we can treat these as a guarantee).Note
sage.databases.sql_db.SQLQuery
functions are available forGraphQuery
. Seesage.databases.sql_db
for more details.INPUT:
graph_db
–GraphDatabase
(default:None
); instance to apply the query to (IfNone
, then a new instance is created)query_dict
– dict (default:None
); a dictionary specifying the query itself. Format is:{'table_name': 'tblname', 'display_cols': ['col1', 'col2'], 'expression': [col, operator, value]}
. If notNone
,query_dict
will take precedence over all other arguments.display_cols
– list of strings (default:None
); a list of column names (strings) to display in the result when running or showing a querykwds
– the columns of the database are all keywords. For a database table/column structure dictionary, callgraph_db_info()
. Keywords accept both single values and lists of length 2. The list allows the user to specify an expression other than equality. Valid expressions are strings, and for numeric values (i.e. Reals and Integers) are: ‘=’,’’,’’,’=’,’=’. String values also accept ‘regexp’ as an expression argument. The only keyword exception to this format isinduced_subgraphs
, which accepts one of the following options:['one_of', String, ..., String]
– will search for graphs containing a subgraph isomorphic to any of thegraph6
strings in the list['all_of', String, ..., String]
– will search for graphs containing a subgraph isomorphic to each of thegraph6
strings in the list
EXAMPLES:
sage: Q = GraphQuery(display_cols=['graph6', 'num_vertices', 'degree_sequence'], num_edges=['<=', 5], min_degree=1) sage: Q.number_of() 35 sage: Q.show() Graph6 Num Vertices Degree Sequence ------------------------------------------------------------ A_ 2 [1, 1] BW 3 [1, 1, 2] CF 4 [1, 1, 1, 3] CK 4 [1, 1, 1, 1] CL 4 [1, 1, 2, 2] CN 4 [1, 2, 2, 3] D?{ 5 [1, 1, 1, 1, 4] D@s 5 [1, 1, 1, 2, 3] D@{ 5 [1, 1, 2, 2, 4] DBg 5 [1, 1, 2, 2, 2] DBk 5 [1, 1, 2, 3, 3] DIk 5 [1, 2, 2, 2, 3] DK[ 5 [1, 2, 2, 2, 3] D_K 5 [1, 1, 1, 1, 2] D`K 5 [1, 1, 2, 2, 2] E?Bw 6 [1, 1, 1, 1, 1, 5] E?Fg 6 [1, 1, 1, 1, 2, 4] E?N? 6 [1, 1, 1, 1, 2, 2] E?NG 6 [1, 1, 1, 1, 3, 3] E@FG 6 [1, 1, 1, 2, 2, 3] E@N? 6 [1, 1, 2, 2, 2, 2] E@Q? 6 [1, 1, 1, 1, 1, 1] E@QW 6 [1, 1, 1, 2, 2, 3] E@YO 6 [1, 1, 2, 2, 2, 2] E_?w 6 [1, 1, 1, 1, 1, 3] E_Cg 6 [1, 1, 1, 1, 2, 2] E_Cw 6 [1, 1, 1, 2, 2, 3] E_Ko 6 [1, 1, 2, 2, 2, 2] F??^? 7 [1, 1, 1, 1, 1, 2, 3] F?LCG 7 [1, 1, 1, 1, 2, 2, 2] FK??W 7 [1, 1, 1, 1, 1, 1, 2] FK?GW 7 [1, 1, 1, 1, 2, 2, 2] F_?@w 7 [1, 1, 1, 1, 1, 1, 4] F_?Hg 7 [1, 1, 1, 1, 1, 2, 3] F_?XO 7 [1, 1, 1, 1, 2, 2, 2]
- get_graphs_list()¶
Return a list of Sage Graph objects that satisfy the query.
EXAMPLES:
sage: Q = GraphQuery(display_cols=['graph6', 'num_vertices', 'degree_sequence'], num_edges=['<=', 5], min_degree=1) sage: L = Q.get_graphs_list() sage: L[0] Graph on 2 vertices sage: len(L) 35
- number_of()¶
Return the number of graphs in the database that satisfy the query.
EXAMPLES:
sage: Q = GraphQuery(display_cols=['graph6', 'num_vertices', 'degree_sequence'] ,num_edges=['<=', 5], min_degree=1) sage: Q.number_of() 35
- query_iterator()¶
Return an iterator over the results list of the
GraphQuery
.EXAMPLES:
sage: Q = GraphQuery(display_cols=['graph6'], num_vertices=7, diameter=5) sage: for g in Q: ....: print(g.graph6_string()) F?`po F?gqg F@?]O F@OKg F@R@o FA_pW FEOhW FGC{o FIAHo sage: Q = GraphQuery(display_cols=['graph6'], num_vertices=7, diameter=5) sage: it = iter(Q) sage: while True: ....: try: print(next(it).graph6_string()) ....: except StopIteration: break F?`po F?gqg F@?]O F@OKg F@R@o FA_pW FEOhW FGC{o FIAHo
- show(max_field_size=20, with_picture=False)¶
Display the results of a query in table format.
INPUT:
max_field_size
– integer (default: 20); width of fields in command prompt versionwith_picture
– boolean (default:False
); whether or not to display results with a picture of the graph (available only in the notebook)
EXAMPLES:
sage: G = GraphDatabase() sage: Q = GraphQuery(G, display_cols=['graph6','num_vertices','aut_grp_size'], num_vertices=4, aut_grp_size=4) sage: Q.show() Graph6 Num Vertices Aut Grp Size ------------------------------------------------------------ C@ 4 4 C^ 4 4
sage: R = GraphQuery(G, display_cols=['graph6','num_vertices','degree_sequence'], num_vertices=4) sage: R.show() Graph6 Num Vertices Degree Sequence ------------------------------------------------------------ C? 4 [0, 0, 0, 0] C@ 4 [0, 0, 1, 1] CB 4 [0, 1, 1, 2] CF 4 [1, 1, 1, 3] CJ 4 [0, 2, 2, 2] CK 4 [1, 1, 1, 1] CL 4 [1, 1, 2, 2] CN 4 [1, 2, 2, 3] C] 4 [2, 2, 2, 2] C^ 4 [2, 2, 3, 3] C~ 4 [3, 3, 3, 3]
Show the pictures (in notebook mode only):
sage: S = GraphQuery(G, display_cols=['graph6','aut_grp_size'], num_vertices=4) sage: S.show(with_picture=True) Traceback (most recent call last): ... NotImplementedError: Cannot display plot on command line.
Note that pictures can be turned off:
sage: S.show(with_picture=False) Graph6 Aut Grp Size ---------------------------------------- C? 24 C@ 4 CB 2 CF 6 CJ 6 CK 8 CL 2 CN 2 C] 8 C^ 4 C~ 24
Show your own query (note that the output is not reformatted for generic queries):
sage: (GenericGraphQuery('select degree_sequence from degrees where max_degree=2 and min_degree >= 1', G)).show() degree_sequence -------------------- 211 222 2211 2222 21111 22211 22211 22222 221111 221111 222211 222211 222211 222222 222222 2111111 2221111 2221111 2221111 2222211 2222211 2222211 2222211 2222222 2222222
- sage.graphs.graph_database.data_to_degseq(data, graph6=None)¶
Convert a database integer data type to a degree sequence list.
INPUT:
data
– integer data type (one digit per vertex representing its degree, sorted high to low) to be converted to a degree sequence listgraph6
– string (default:None
); thegraph6
identifier is required for all graphs with no edges, so that the correct number of zeros is returned.
EXAMPLES:
sage: from sage.graphs.graph_database import data_to_degseq sage: data_to_degseq(3221) [1, 2, 2, 3] sage: data_to_degseq(0, 'D??') [0, 0, 0, 0, 0]
- sage.graphs.graph_database.degseq_to_data(degree_sequence)¶
Convert a degree sequence list to a sorted (max-min) integer data type.
The input degree sequence list (of Integers) is converted to a sorted (max-min) integer data type, as used for faster access in the underlying database.
INPUT:
degree_sequence
– list of integers; input degree sequence list
EXAMPLES:
sage: from sage.graphs.graph_database import degseq_to_data sage: degseq_to_data([2,2,3,1]) 3221
- sage.graphs.graph_database.graph6_to_plot(graph6)¶
Return a
Graphics
object from agraph6
string.This method constructs a graph from a
graph6
string and returns asage.plot.graphics.Graphics
object with arguments preset for thesage.plot.graphics.Graphics.show()
method.INPUT:
graph6
– agraph6
string
EXAMPLES:
sage: from sage.graphs.graph_database import graph6_to_plot sage: type(graph6_to_plot('D??')) <class 'sage.plot.graphics.Graphics'>
- sage.graphs.graph_database.graph_db_info(tablename=None)¶
Return a dictionary of allowed table and column names.
INPUT:
tablename
– restricts the output to a single table
EXAMPLES:
sage: sorted(graph_db_info()) ['aut_grp', 'degrees', 'graph_data', 'misc', 'spectrum']
sage: graph_db_info(tablename='graph_data') ['complement_graph6', 'eulerian', 'graph6', 'lovasz_number', 'num_cycles', 'num_edges', 'num_hamiltonian_cycles', 'num_vertices', 'perfect', 'planar']
- sage.graphs.graph_database.subgraphs_to_query(subgraphs, db)¶
Return a GraphQuery object required for the induced_subgraphs parameter.
This method constructs and returns a
GraphQuery
object respecting the special input required for theinduced_subgraphs
parameter.INPUT:
subgraphs
– list of strings; the list should be of one of the following two formats:['one_of', String, ..., String]
– will search for graphs containing a subgraph isomorphic to any of thegraph6
strings in the list['all_of', String, ..., String]
– will search for graphs containing a subgraph isomorphic to each of thegraph6
strings in the list
db
– aGraphDatabase
Note
This is a helper method called by the
GraphQuery
constructor to handle this special format. This method should not be used on its own because it doesn’t set any display columns in the query string, causing a failure to fetch the data when run.EXAMPLES:
sage: from sage.graphs.graph_database import subgraphs_to_query sage: gd = GraphDatabase() sage: q = subgraphs_to_query(['all_of', 'A?', 'B?', 'C?'], gd) sage: q.get_query_string() 'SELECT ,,,,, FROM misc WHERE ( ( misc.induced_subgraphs regexp ? ) AND ( misc.induced_subgraphs regexp ? ) ) AND ( misc.induced_subgraphs regexp ? )'