def 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 list - ``graph6`` -- string (default: ``None``); the ``graph6`` 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] """ degseq = Integer(data).digits(10) if not degseq: # compute number of 0's in list from graph6 string from sage.graphs.generic_graph_pyx import length_and_string_from_graph6 return length_and_string_from_graph6(str(graph6))[0] * [0] else: return degseq
def data_to_degseq(data, graph6=None): """ Takes the database integer data type (one digit per vertex representing its degree, sorted high to low) and converts it to degree sequence list. The graph6 identifier is required for all graphs with no edges, so that the correct number of zeros will be returned. EXAMPLE:: 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] """ degseq = Integer(data).digits(10) if not degseq: # compute number of 0's in list from graph6 string from sage.graphs.generic_graph_pyx import length_and_string_from_graph6 return length_and_string_from_graph6(str(graph6))[0]*[0] else: return degseq