Module: sage.graphs.graph_database
Graph Database Module
INFO:
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.database.py). The display functions and get_list create their own queries, but it is also possible to query the database by constructing either a GenericSQLQuery or a SQLQuery.
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 skeleton:
{'aut_grp': {'aut_grp_size': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'edge_transitive': {'index': True, 'primary_key': False, 'sql': 'BOOLEAN'}, 'graph_id': {'index': False, 'primary_key': False, 'sql': 'INTEGER'}, 'num_fixed_points': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'num_orbits': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'vertex_transitive': {'index': True, 'primary_key': False, 'sql': 'BOOLEAN'}}, 'degrees': {'average_degree': {'index': True, 'primary_key': False, 'sql': 'REAL'}, 'degree_sequence': {'index': False, 'primary_key': False, 'sql': 'INTEGER'}, 'degrees_sd': {'index': True, 'primary_key': False, 'sql': 'REAL'}, 'graph_id': {'index': False, 'primary_key': False, 'sql': 'INTEGER'}, 'max_degree': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'min_degree': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'regular': {'index': True, 'primary_key': False, 'sql': 'BOOLEAN'}}, 'graph_data': {'complement_graph6': {'index': True, 'primary_key': False, 'sql': 'TEXT'}, 'eulerian': {'index': True, 'primary_key': False, 'sql': 'BOOLEAN'}, 'graph6': {'index': True, 'primary_key': False, 'sql': 'TEXT'}, 'graph_id': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'lovasz_number': {'index': True, 'primary_key': False, 'sql': 'REAL'}, 'num_cycles': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'num_edges': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'num_hamiltonian_cycles': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'num_vertices': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'perfect': {'index': True, 'primary_key': False, 'sql': 'BOOLEAN'}, 'planar': {'index': True, 'primary_key': False, 'sql': 'BOOLEAN'}}, 'misc': {'clique_number': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'diameter': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'edge_connectivity': {'index': True, 'primary_key': False, 'sql': 'BOOLEAN'}, 'girth': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'graph_id': {'index': False, 'primary_key': False, 'sql': 'INTEGER'}, 'independence_number': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'induced_subgraphs': {'index': True, 'primary_key': False, 'sql': 'TEXT'}, 'min_vertex_cover_size': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'num_components': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'num_cut_vertices': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'num_spanning_trees': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'radius': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'vertex_connectivity': {'index': True, 'primary_key': False, 'sql': 'BOOLEAN'}}, 'spectrum': {'eigenvalues_sd': {'index': True, 'primary_key': False, 'sql': 'REAL'}, 'energy': {'index': True, 'primary_key': False, 'sql': 'REAL'}, 'graph_id': {'index': False, 'primary_key': False, 'sql': 'INTEGER'}, 'max_eigenvalue': {'index': True, 'primary_key': False, 'sql': 'REAL'}, 'min_eigenvalue': {'index': True, 'primary_key': False, 'sql': 'REAL'}, 'spectrum': {'index': False, 'primary_key': False, 'sql': 'TEXT'}}}
The automatically generated queries will search graph_data automatically, and the other tables will be searched as necessary. (Display functions require that all tablesbe searched).
USE: The tables are associated by the unique primary key graph_id (int).
For the query generating functions (display functions and get_list), the query parameter allows the user to input any GenericSQLQuery associated with this database. Otherwise, the user can enter the individual parameters and the sqlite call will be generated by the function.
The properties currently used as search parameters are:
Table: aut_grp - aut_grp_size (The size of the automorphism group - Integer) - edge_transitive (Boolean) - num_fixed_points (Integer) - num_orbits (Integer) - vertex_transitive (Boolean) Table: degrees - average_degree (Real) - degree_sequence (Integer) - degrees_sd (Standard Deviation of degrees - Real) - max_degree (Integer) - min_degree (Integer) - regular (Boolean) Table: graph_data - complement_graph6 (graph6 canonical label of the complement graph - String) - eulerian (Boolean) - graph6 (canonical label - String) - lovasz_number (Real) - num_cycles (Integer) - num_edges (Integer) - num_hamiltonian_cycles (Integer) - num_vertices (Integer) - perfect (Boolean) - planar (Boolean) Table: misc - clique_number (Integer) - diameter (Real) - edge_connectivity (Integer) - girth (Integer) - independence_number (Integer) - induced_subgraphs (canonical label, use regexp - String) - min_vertex_cover_size (Integer) - num_components (Integer) - num_cut_vertices (Integer) - num_spanning_trees (Integer) - radius (Real) - vertex_connectivity (Integer) Table: spectrum - eigenvalues_sd (Standard Deviation of eigenvalues - Real) - energy (Real) - max_eigenvalue (Real) - min_eigenvalue (Real) - spectrum (String)
VISUALIZATION:
Beyond the typical show function, there are three options for displaying the results of a query. When running the notebook, each of these functions displays an image of the graph and it's (canonical label) graph6 string in an html results table.
- display_all (displays all the database properties in the results table). - display_tables (displays all the properties in the database tables that are listed by the user). - display_properties (displays all the individual properties specified by the user).
Author Log:
REFERENCES: - Data provided by Jason Grout (Brigham Young University). [Online] Available: http://math.byu.edu/ grout/graphs/
Module-level Functions
b, j) |
expr, item) |
Function to define regular expressions in pysqlite. Returns 1 if parameter `item` matches the regular expression parameter `expr`. Returns 0 otherwise (i.e.: no match).
REFERENCES: Gerhard Haring. [Online] Available: http://lists.initd.org/pipermail/pysqlite/2005-November/000253.html
Class: GenericGraphQuery
Input:
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...
See GraphDatabase class docstrings or enter:
sage: G = GraphDatabase() sage: G.get_skeleton() {...
to see the underlying structure of the database. Also see GenericSQLQuery in sage.databases.database 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 the param_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 = GenericSQLQuery(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
self, database, query_string, [param_tuple=None]) |
Functions: show
self, [max_field_size=20], [html_table=False], [with_picture=None]) |
Displays the results of a query in table format.
Input:
sage: G = GraphDatabase() sage: Q = GraphQuery(G, num_vertices=4, aut_grp_size=4, display=['graph6','num_vertices','aut_grp_size']) sage: Q.show() graph6 num_vertices aut_grp_size ------------------------------------------------------------ C@ 4 4 C^ 4 4
sage: R = GraphQuery(G, num_vertices=4, display=['graph6','num_vertices','degree_sequence']) sage: R.show() graph6 num_vertices degree_sequence ------------------------------------------------------------ C? 4 0 C@ 4 1100 CB 4 2110 CK 4 1111 CF 4 3111 CJ 4 2220 CL 4 2211 CN 4 3221 C] 4 2222 C^ 4 3322 C~ 4 3333
Show the pictures (in notebook mode only):
sage: S = GraphQuery(G, num_vertices=4, display=['graph6','aut_grp_size']) sage: S.show() graph6 aut_grp_size ---------------------------------------- C? 24 C@ 4 CB 2 CK 8 CF 6 CJ 6 CL 2 CN 2 C] 8 C^ 4 C~ 24
Note that pictures can be turned off:
sage: S.show(with_picture=False) graph6 aut_grp_size ---------------------------------------- C? 24 C@ 4 CB 2 CK 8 CF 6 CJ 6 CL 2 CN 2 C] 8 C^ 4 C~ 24
Show your own query:
sage: (GenericGraphQuery(G, 'select degree_sequence from degrees where max_degree=2 and min_degree >= 1')).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
Special Functions: __init__
Class: GraphDatabase
INFO:
This class interfaces with the sqlite database graphs.db. It is an immutable database that inherits from SQLDatabase (see sage.databases.database.py). The display functions and get_list create their own queries, but it is also possible to query the database by constructing either a GenericSQLQuery or a SQLQuery.
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 skeleton:
{'aut_grp': {'aut_grp_size': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'edge_transitive': {'index': True, 'primary_key': False, 'sql': 'BOOLEAN'}, 'graph_id': {'index': False, 'primary_key': False, 'sql': 'INTEGER'}, 'num_fixed_points': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'num_orbits': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'vertex_transitive': {'index': True, 'primary_key': False, 'sql': 'BOOLEAN'}}, 'degrees': {'average_degree': {'index': True, 'primary_key': False, 'sql': 'REAL'}, 'degree_sequence': {'index': False, 'primary_key': False, 'sql': 'INTEGER'}, 'degrees_sd': {'index': True, 'primary_key': False, 'sql': 'REAL'}, 'graph_id': {'index': False, 'primary_key': False, 'sql': 'INTEGER'}, 'max_degree': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'min_degree': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'regular': {'index': True, 'primary_key': False, 'sql': 'BOOLEAN'}}, 'graph_data': {'complement_graph6': {'index': True, 'primary_key': False, 'sql': 'TEXT'}, 'eulerian': {'index': True, 'primary_key': False, 'sql': 'BOOLEAN'}, 'graph6': {'index': True, 'primary_key': False, 'sql': 'TEXT'}, 'graph_id': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'lovasz_number': {'index': True, 'primary_key': False, 'sql': 'REAL'}, 'num_cycles': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'num_edges': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'num_hamiltonian_cycles': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'num_vertices': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'perfect': {'index': True, 'primary_key': False, 'sql': 'BOOLEAN'}, 'planar': {'index': True, 'primary_key': False, 'sql': 'BOOLEAN'}}, 'misc': {'clique_number': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'diameter': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'edge_connectivity': {'index': True, 'primary_key': False, 'sql': 'BOOLEAN'}, 'girth': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'graph_id': {'index': False, 'primary_key': False, 'sql': 'INTEGER'}, 'independence_number': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'induced_subgraphs': {'index': True, 'primary_key': False, 'sql': 'TEXT'}, 'min_vertex_cover_size': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'num_components': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'num_cut_vertices': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'num_spanning_trees': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'radius': {'index': True, 'primary_key': False, 'sql': 'INTEGER'}, 'vertex_connectivity': {'index': True, 'primary_key': False, 'sql': 'BOOLEAN'}}, 'spectrum': {'eigenvalues_sd': {'index': True, 'primary_key': False, 'sql': 'REAL'}, 'energy': {'index': True, 'primary_key': False, 'sql': 'REAL'}, 'graph_id': {'index': False, 'primary_key': False, 'sql': 'INTEGER'}, 'max_eigenvalue': {'index': True, 'primary_key': False, 'sql': 'REAL'}, 'min_eigenvalue': {'index': True, 'primary_key': False, 'sql': 'REAL'}, 'spectrum': {'index': False, 'primary_key': False, 'sql': 'TEXT'}}}
The automatically generated queries will search graph_data automatically, and the other tables will be searched as necessary. (Display functions require that all tablesbe searched).
USE: The tables are associated by the unique primary key graph_id (int).
For the query generating functions (display functions and get_list), the query parameter allows the user to input any GenericSQLQuery associated with this database. Otherwise, the user can enter the individual parameters and the sqlite call will be generated by the function.
The properties currently used as search parameters are:
Table: aut_grp - aut_grp_size (The size of the automorphism group - Integer) - edge_transitive (Boolean) - num_fixed_points (Integer) - num_orbits (Integer) - vertex_transitive (Boolean) Table: degrees - average_degree (Real) - degree_sequence (Integer) - degrees_sd (Standard Deviation of degrees - Real) - max_degree (Integer) - min_degree (Integer) - regular (Boolean) Table: graph_data - complement_graph6 (graph6 canonical label of the complement graph - String) - eulerian (Boolean) - graph6 (canonical label - String) - lovasz_number (Real) - num_cycles (Integer) - num_edges (Integer) - num_hamiltonian_cycles (Integer) - num_vertices (Integer) - perfect (Boolean) - planar (Boolean) Table: misc - clique_number (Integer) - diameter (Real) - edge_connectivity (Integer) - girth (Integer) - independence_number (Integer) - induced_subgraphs (canonical label, use regexp - String) - min_vertex_cover_size (Integer) - num_components (Integer) - num_cut_vertices (Integer) - num_spanning_trees (Integer) - radius (Real) - vertex_connectivity (Integer) Table: spectrum - eigenvalues_sd (Standard Deviation of eigenvalues - Real) - energy (Real) - max_eigenvalue (Real) - min_eigenvalue (Real) - spectrum (String)
VISUALIZATION:
Beyond the typical show function, there are three options for displaying the results of a query. When running the notebook, each of these functions displays an image of the graph and it's (canonical label) graph6 string in an html results table.
- display_all (displays all the database properties in the results table). - display_tables (displays all the properties in the database tables that are listed by the user). - display_properties (displays all the individual properties specified by the user).
REFERENCES: - Data provided by Jason Grout (Brigham Young University). [Online] Available: http://math.byu.edu/ grout/graphs/
self) |
Functions: display_all,
display_properties,
display_tables,
get_list,
number_of
self, [query=None], [layout=circular], [graph6=None], [num_vertices=None], [num_edges=None], [num_cycles=None], [num_hamiltonian_cycles=None], [eulerian=None], [planar=None], [perfect=None], [lovasz_number=None], [complement_graph6=None], [aut_grp_size=None], [num_orbits=None], [num_fixed_points=None], [vertex_transitive=None], [edge_transitive=None], [degree_sequence=None], [min_degree=None], [max_degree=None], [average_degree=None], [degrees_sd=None], [regular=None], [vertex_connectivity=None], [edge_connectivity=None], [num_components=None], [girth=None], [radius=None], [diameter=None], [clique_number=None], [independence_number=None], [num_cut_vertices=None], [min_vertex_cover_size=None], [num_spanning_trees=None], [induced_subgraphs=None], [spectrum=None], [min_eigenvalue=None], [max_eigenvalue=None], [eigenvalues_sd=None], [energy=None]) |
Displays the results of a query in a table, including all stored properties and an image for each graph.
Input:
The basics:
sage: G = GraphDatabase() sage: G.display_all(num_vertices=5,lovasz_number=3.0,\ ... girth=4,radius=2,diameter=3) <html>...
sage: G.display_all(layout='spring',num_hamiltonian_cycles=2,\ ... regular=True,perfect=False) <html>... sage: G.display_all(layout='spring',degree_sequence=433211) <html>...
Compare results:
sage: (Graph('EAMw')).is_isomorphic(Graph('E@NW')) False
Using Inequalities:
sage: G.display_all(layout='circular', min_eigenvalue=['=',-1], \ ... eigenvalues_sd=['<=',1], energy=['>',5]) <html>...
The query argument:
sage: Q = GenericGraphQuery(G, 'SELECT graph_data.graph6 \ ... FROM graph_data WHERE num_vertices<=4 \ ... and num_edges>3') sage: G.display_all(layout='spring', query=Q) <html>... sage: R = GraphQuery(G, eulerian=1, regular=0, planar=1, num_cycles=['<=',1]) sage: G.display_all(query=R) <html>... sage: S = GenericGraphQuery(G, "SELECT graph_data.graph6 \ ... FROM graph_data INNER JOIN misc on \ ... misc.graph_id=graph_data.graph_id WHERE \ ... misc.induced_subgraphs regexp '.*E~~w.*'") sage: G.display_all(query=S) # long time <html>...
self, [properties=None], [layout=circular], [query=None], [graph6=None], [num_vertices=None], [num_edges=None], [num_cycles=None], [num_hamiltonian_cycles=None], [eulerian=None], [planar=None], [perfect=None], [lovasz_number=None], [complement_graph6=None], [aut_grp_size=None], [num_orbits=None], [num_fixed_points=None], [vertex_transitive=None], [edge_transitive=None], [degree_sequence=None], [min_degree=None], [max_degree=None], [average_degree=None], [degrees_sd=None], [regular=None], [vertex_connectivity=None], [edge_connectivity=None], [num_components=None], [girth=None], [radius=None], [diameter=None], [clique_number=None], [independence_number=None], [num_cut_vertices=None], [min_vertex_cover_size=None], [num_spanning_trees=None], [induced_subgraphs=None], [spectrum=None], [min_eigenvalue=None], [max_eigenvalue=None], [eigenvalues_sd=None], [energy=None]) |
Displays the results of a query in a table, including all specified properties and an image for each graph.
Input:
The basics:
sage: graphs_query = GraphDatabase() sage: graphs_query.display_properties(properties=['num_vertices','lovasz_number',\ ... 'girth','radius','diameter'], num_vertices=5,\ ... lovasz_number=3.0, girth=4, radius=2, diameter=3) <html>... sage: graphs_query.display_properties(properties=['num_hamiltonian_cycles','regular',\ ... 'perfect','num_cycles','num_edges','spectrum'], \ ... layout='spring', num_hamiltonian_cycles=2,\ ... regular=True, perfect=False) <html>... sage: graphs_query.display_properties(properties=['min_degree','max_degree',\ ... 'degrees_sd','average_degree','regular',\ ... 'induced_subgraphs'],layout='spring',\ ... degree_sequence=433211) <html>...
Using Inequalities:
sage: graphs_query.display_properties(properties=['energy','spectrum','eigenvalues_sd',\ ... 'complement_graph6'], layout='circular', \ ... min_eigenvalue=['=',-1], eigenvalues_sd=['<=',1], \ ... energy=['>',5]) <html>...
The query argument:
sage: Q = GenericGraphQuery(graphs_query, 'SELECT graph_data.graph6 \ ... FROM graph_data WHERE num_vertices<=4 \ ... and num_edges>3') sage: graphs_query.display_properties(properties=['eulerian','perfect','planar','regular',\ ... 'edge_transitive','vertex_transitive','num_cycles','degree_ sequence',\ ... 'induced_subgraphs','num_vertices','max_degree'], layout='spring', \ ... query=Q) <html>... sage: R = GenericGraphQuery(graphs_query, 'SELECT graph_data.graph6 FROM graph_data \ ... INNER JOIN degrees on graph_data.graph_id=degrees.graph_id \ ... WHERE num_vertices>6 and eulerian=1 and regular=0 and planar=1 \ ... and num_cycles<=2') sage: graphs_query.display_properties(query=R, properties=['clique_number','independence_number']) <html>... sage: S = GenericGraphQuery(graphs_query, "SELECT graph_data.graph6 \ ... FROM graph_data INNER JOIN misc on \ ... misc.graph_id=graph_data.graph_id WHERE \ ... misc.induced_subgraphs regexp '.*E~~w.*'") sage: graphs_query.display_properties(query=S, properties=['induced_subgraphs']) # long time <html>...
self, [tables=None], [layout=circular], [query=None], [graph6=None], [num_vertices=None], [num_edges=None], [num_cycles=None], [num_hamiltonian_cycles=None], [eulerian=None], [planar=None], [perfect=None], [lovasz_number=None], [complement_graph6=None], [aut_grp_size=None], [num_orbits=None], [num_fixed_points=None], [vertex_transitive=None], [edge_transitive=None], [degree_sequence=None], [min_degree=None], [max_degree=None], [average_degree=None], [degrees_sd=None], [regular=None], [vertex_connectivity=None], [edge_connectivity=None], [num_components=None], [girth=None], [radius=None], [diameter=None], [clique_number=None], [independence_number=None], [num_cut_vertices=None], [min_vertex_cover_size=None], [num_spanning_trees=None], [induced_subgraphs=None], [spectrum=None], [min_eigenvalue=None], [max_eigenvalue=None], [eigenvalues_sd=None], [energy=None]) |
Displays the results of a query in a table, including all stored properties FROM the specified database tables and an image for each graph.
Input:
The basics:
sage: G = GraphDatabase() sage: G.display_tables(tables=['graph_data','misc'], num_vertices=5,\ ... lovasz_number=3.0, girth=4, radius=2, diameter=3) <html>... sage: G.display_tables(tables=['degrees','spectrum','aut_grp','misc'], \ ... layout='spring', num_hamiltonian_cycles=2,\ ... regular=True, perfect=False) <html>... sage: G.display_tables(tables=['degrees'],layout='spring',\ ... degree_sequence=433211) <html>...
Using Inequalities:
sage: G.display_tables(tables=['spectrum'], layout='circular', \ ... min_eigenvalue=['=',-1], eigenvalues_sd=['<=',1], \ ... energy=['>',5]) <html>...
The query parameter:
sage: Q = GenericGraphQuery(G, 'SELECT graph_data.graph6 \ ... FROM graph_data WHERE num_vertices<=4 \ ... and num_edges>3') sage: G.display_tables(tables=['graph_data'], layout='spring', query=Q) ... <html>... sage: R = GenericGraphQuery(G, 'SELECT graph_data.graph6 FROM graph_data \ ... INNER JOIN degrees on graph_data.graph_id=degrees.graph_id \ ... WHERE num_vertices>6 and eulerian=1 and regular=0 and planar=1 \ ... and num_cycles<=2') sage: G.display_tables(query=R, tables=['graph_data','degrees']) <html>... sage: S = GenericGraphQuery(G, "SELECT graph_data.graph6 \ ... FROM graph_data INNER JOIN misc on \ ... misc.graph_id=graph_data.graph_id WHERE \ ... misc.induced_subgraphs regexp '.*E~~w.*'") sage: G.display_tables(query=S, tables=['graph_data','misc','spectrum','degrees','aut_grp']) # long time <html>...
self, [query=None], [graph6=None], [num_vertices=None], [num_edges=None], [num_cycles=None], [num_hamiltonian_cycles=None], [eulerian=None], [planar=None], [perfect=None], [lovasz_number=None], [complement_graph6=None], [aut_grp_size=None], [num_orbits=None], [num_fixed_points=None], [vertex_transitive=None], [edge_transitive=None], [degree_sequence=None], [min_degree=None], [max_degree=None], [average_degree=None], [degrees_sd=None], [regular=None], [vertex_connectivity=None], [edge_connectivity=None], [num_components=None], [girth=None], [radius=None], [diameter=None], [clique_number=None], [independence_number=None], [num_cut_vertices=None], [min_vertex_cover_size=None], [num_spanning_trees=None], [induced_subgraphs=None], [spectrum=None], [min_eigenvalue=None], [max_eigenvalue=None], [eigenvalues_sd=None], [energy=None]) |
Returns a list of SAGE graphs according to provided parameters.
Input:
sage: G = GraphDatabase() sage: lis = G.get_list(num_vertices=5,lovasz_number=3.0,\ ... girth=4,radius=2,diameter=3) ... sage: len(lis) 1 sage: lis[0].show(layout='circular',figsize=[2,2],vertex_size=0,graph_border=True) sage: lis = G.get_list(degree_sequence=433211) sage: graphs_list.to_graph6(lis) 'E@NW\nEAMw\n' sage: lis = G.get_list(min_eigenvalue=['=',-1], \ ... eigenvalues_sd=['<=',1], energy=['>',5]) ... sage: len(lis) == G.number_of(min_eigenvalue=['=',-1], \ ... eigenvalues_sd=['<=',1], energy=['>',5]) True sage: lis = G.get_list(num_hamiltonian_cycles=2,regular=True,perfect=False) sage: graphs_list.show_graphs(lis)
self, [query=None], [graph6=None], [num_vertices=None], [num_edges=None], [num_cycles=None], [num_hamiltonian_cycles=None], [eulerian=None], [planar=None], [perfect=None], [lovasz_number=None], [complement_graph6=None], [aut_grp_size=None], [num_orbits=None], [num_fixed_points=None], [vertex_transitive=None], [edge_transitive=None], [degree_sequence=None], [min_degree=None], [max_degree=None], [average_degree=None], [degrees_sd=None], [regular=None], [vertex_connectivity=None], [edge_connectivity=None], [num_components=None], [girth=None], [radius=None], [diameter=None], [clique_number=None], [independence_number=None], [num_cut_vertices=None], [min_vertex_cover_size=None], [num_spanning_trees=None], [induced_subgraphs=None], [spectrum=None], [min_eigenvalue=None], [max_eigenvalue=None], [eigenvalues_sd=None], [energy=None]) |
Returns the integer that represents the number of unlabeled graphs with 7 or fewer vertices that meet the provided search parameters.
Input:
sage: graphs_query = GraphDatabase() sage: graphs_query.number_of() 1252 sage: g = graphs_query.get_list(num_vertices=5,lovasz_number=3.0,\ ... girth=4,radius=2,diameter=3) ... sage: h = graphs_query.number_of(num_vertices=5,lovasz_number=3.0,\ ... girth=4,radius=2,diameter=3) ... sage: h == len(g) True sage: for i in range(8)[1:]: ... g = graphs_query.number_of(num_vertices=i) ... h = graphs_query.get_list(num_vertices=i) ... print g == len(h) True True True True True True True sage: graphs_query.number_of(degree_sequence=433211) 2 sage: graphs_query.number_of(min_eigenvalue=['=',-1], \ ... eigenvalues_sd=['<=',1], energy=['>',5]) 2 sage: graphs_query.number_of(num_hamiltonian_cycles=2,regular=True,perfect=False) 2 sage: graphs_query.number_of(num_vertices=7,num_cycles=['>',2]) 913 sage: a = graphs_query.number_of(num_hamiltonian_cycles=['>=',2]) sage: b = graphs_query.number_of(num_hamiltonian_cycles=['<',2]) sage: c = graphs_query.number_of(num_hamiltonian_cycles=['<=',40]) sage: d = graphs_query.number_of(num_hamiltonian_cycles=['>',40]) sage: a-d == c-b True
Special Functions: __init__
Class: GraphQuery
NOTE: SQLQuery functions are available for GraphQuery.
Input:
self, database, [display=['graph6']], [graph6=None], [num_vertices=None], [num_edges=None], [num_cycles=None], [num_hamiltonian_cycles=None], [eulerian=None], [planar=None], [perfect=None], [lovasz_number=None], [complement_graph6=None], [aut_grp_size=None], [num_orbits=None], [num_fixed_points=None], [vertex_transitive=None], [edge_transitive=None], [degree_sequence=None], [min_degree=None], [max_degree=None], [average_degree=None], [degrees_sd=None], [regular=None], [vertex_connectivity=None], [edge_connectivity=None], [num_components=None], [girth=None], [radius=None], [diameter=None], [clique_number=None], [independence_number=None], [num_cut_vertices=None], [min_vertex_cover_size=None], [num_spanning_trees=None], [induced_subgraphs=None], [spectrum=None], [min_eigenvalue=None], [max_eigenvalue=None], [eigenvalues_sd=None], [energy=None]) |
Functions: complement,
intersect,
union
self) |
Returns a GraphQuery that is the complement of self.
sage: G = GraphDatabase() sage: more_than_one = GraphQuery(G, num_vertices=['>',1], display=['graph6','num_vertices','num_edges']) sage: one = more_than_one.complement() sage: one.show() graph6 num_vertices num_edges ------------------------------------------------------------ @ 1 0
Let's explore a combination of these logical statements:
sage: G = GraphDatabase() sage: Q = GraphQuery(G, num_vertices=4, aut_grp_size=4, display=['graph6','num_vertices','aut_grp_size']) sage: Q.show() graph6 num_vertices aut_grp_size ------------------------------------------------------------ C@ 4 4 C^ 4 4
sage: R = GraphQuery(G, num_vertices=4, display=['graph6','num_vertices','degree_sequence']) sage: R.show() graph6 num_vertices degree_sequence ------------------------------------------------------------ C? 4 0 C@ 4 1100 CB 4 2110 CK 4 1111 CF 4 3111 CJ 4 2220 CL 4 2211 CN 4 3221 C] 4 2222 C^ 4 3322 C~ 4 3333
sage: T = Q.intersect(R) sage: T.show() graph6 num_vertices aut_grp_size graph6 num_vertices degree_sequence --------------------------------------------------------------------------- --------------------------------------------- C@ 4 4 C@ 4 1100 C^ 4 4 C^ 4 3322
sage: U = Q.complement() sage: V = U.intersect(R) sage: V.show() graph6 num_vertices aut_grp_size graph6 num_vertices degree_sequence --------------------------------------------------------------------------- --------------------------------------------- C? 4 24 C? 4 0 CB 4 2 CB 4 2110 CK 4 8 CK 4 1111 CF 4 6 CF 4 3111 CJ 4 6 CJ 4 2220 CL 4 2 CL 4 2211 CN 4 2 CN 4 3221 C] 4 8 C] 4 2222 C~ 4 24 C~ 4 3333
self, other) |
Returns a GraphQuery that is the intersection of two input GraphQuery instances: self and other.
Display columns are concatenated in order: self, other.
Input:
sage: G = GraphDatabase() sage: Q = GraphQuery(G, num_vertices=4, aut_grp_size=4, display=['graph6','num_vertices','aut_grp_size']) sage: Q.get_query_string() ' SELECT graph_data.graph6, graph_data.num_vertices, aut_grp.aut_grp_size FROM graph_data INNER JOIN aut_grp on aut_grp.graph_id=graph_data.graph_id WHERE graph_data.graph_id=graph_data.graph_id and aut_grp.aut_grp_size=4 and graph_data.num_vertices=4' sage: R = GraphQuery(G, num_vertices=4, display=['graph6','num_vertices','degree_sequence']) sage: R.get_query_string() ' SELECT graph_data.graph6, graph_data.num_vertices, degrees.degree_sequence FROM graph_data INNER JOIN degrees on graph_data.graph_id=degrees.graph_id WHERE graph_data.graph_id=graph_data.graph_id and graph_data.num_vertices=4' sage: T = Q.intersect(R) sage: T.get_query_string() ' SELECT graph_data.graph6, graph_data.num_vertices, aut_grp.aut_grp_size,graph_data.graph6, graph_data.num_vertices, degrees.degree_sequence FROM graph_data INNER JOIN aut_grp on aut_grp.graph_id=graph_data.graph_id INNER JOIN degrees on graph_data.graph_id=degrees.graph_id WHERE ( graph_data.graph_id=graph_data.graph_id and aut_grp.aut_grp_size=4 and graph_data.num_vertices=4 ) AND ( graph_data.graph_id=graph_data.graph_id and graph_data.num_vertices=4 )'
sage: G = GraphDatabase() sage: more_than_one = GraphQuery(G, num_vertices=['>',1]) sage: three = GraphQuery(G, num_vertices=3) sage: intersection = more_than_one.intersect(three) sage: intersection.get_query_string() ' SELECT graph_data.graph6,graph_data.graph6 FROM graph_data WHERE ( graph_data.graph_id=graph_data.graph_id and graph_data.num_vertices>1 ) AND ( graph_data.graph_id=graph_data.graph_id and graph_data.num_vertices=3 )' sage: intersection.show() graph6 graph6 ---------------------------------------- B? B? BG BG BW BW Bw Bw
self, other) |
Returns a GraphQuery that is the intersection of two input GraphQuery instances: self and other.
Display columns are concatenated in order: self, other.
Input:
sage: G = GraphDatabase() sage: more_than_one = GraphQuery(G, num_vertices=['>',1]) sage: three = GraphQuery(G, num_vertices=3) sage: union = more_than_one.union(three) sage: union.get_query_string() ' SELECT graph_data.graph6,graph_data.graph6 FROM graph_data WHERE ( graph_data.graph_id=graph_data.graph_id and graph_data.num_vertices>1 ) OR ( graph_data.graph_id=graph_data.graph_id and graph_data.num_vertices=3 )' sage: len(union.run_query()) 1251 sage: len(more_than_one.run_query()) 1251
Special Functions: __init__
See About this document... for information on suggesting changes.