def read_graph_from_string(txt):
if not txt.startswith('<STR_LIT:{>'):<EOL><INDENT>return read_dot(txt)  <EOL><DEDENT>def conv(value):<EOL><INDENT>if isinstance(value, str):<EOL><INDENT>return '<STR_LIT:">' + value + '<STR_LIT:">'<EOL><DEDENT>else:<EOL><INDENT>return value<EOL><DEDENT><DEDENT>doc = literal_eval(txt)<EOL>g = digraph()<EOL>for attrs, values in doc.get("<STR_LIT>", []):<EOL><INDENT>attrs = [(k, conv(v)) for k, v in attrs]<EOL>for value in values:<EOL><INDENT>if isinstance(value, str):<EOL><INDENT>node_name = value<EOL>attrs_ = attrs<EOL><DEDENT>else:<EOL><INDENT>node_name, label = value<EOL>attrs_ = attrs + [("<STR_LIT:label>", conv(label))]<EOL><DEDENT>g.add_node(node_name, attrs=attrs_)<EOL><DEDENT><DEDENT>for attrs, values in doc.get("<STR_LIT>", []):<EOL><INDENT>attrs_ = [(k, conv(v)) for k, v in attrs]<EOL>for value in values:<EOL><INDENT>if len(value) == <NUM_LIT:3>:<EOL><INDENT>edge = value[:<NUM_LIT:2>]<EOL>label = value[-<NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>edge = value<EOL>label = '<STR_LIT>'<EOL><DEDENT>g.add_edge(edge, label=label, attrs=attrs_)<EOL><DEDENT><DEDENT>return g<EOL>
Read a graph from a string, either in dot format, or our own
    compressed format.

    Returns:
        `pygraph.digraph`: Graph object.