def graph_from_incidence_matrix(matrix, node_prefix='<STR_LIT>', directed=False):
node_orig = <NUM_LIT:1><EOL>if directed:<EOL><INDENT>graph = Dot(graph_type='<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>graph = Dot(graph_type='<STR_LIT>')<EOL><DEDENT>for row in matrix:<EOL><INDENT>nodes = []<EOL>c = <NUM_LIT:1><EOL>for node in row:<EOL><INDENT>if node:<EOL><INDENT>nodes.append(c*node)<EOL><DEDENT>c += <NUM_LIT:1><EOL>nodes.sort()<EOL><DEDENT>if len(nodes) == <NUM_LIT:2>:<EOL><INDENT>graph.add_edge( <EOL>Edge( node_prefix + abs(nodes[<NUM_LIT:0>]), <EOL>node_prefix + nodes[<NUM_LIT:1>] ))<EOL><DEDENT><DEDENT>if not directed:<EOL><INDENT>graph.set_simplify(True)<EOL><DEDENT>return graph<EOL>
Creates a basic graph out of an incidence matrix.

    The matrix has to be a list of rows of values
    representing an incidence matrix.
    The values can be anything: bool, int, float, as long
    as they can evaluate to True or False.