nodes: 0, module; 1, function_definition; 2, function_name:to_digraph; 3, parameters; 4, block; 5, identifier:self; 6, list_splat_pattern; 7, dictionary_splat_pattern; 8, expression_statement; 9, comment:# TODO: make test for this; 10, expression_statement; 11, for_statement; 12, return_statement; 13, identifier:args; 14, identifier:kwargs; 15, comment:"""
          Compute a directed graph for the chemical system.
  
          Returns
          -------
          digraph : `networkx.DiGraph`
              Graph nodes are reactants and/or products of chemical equations,
              while edges represent the equations themselves. Double ended edges
              are used to represent equilibria. Attributes are computed with
              `ChemicalEquation.to_series` for each equation (see examples
              below).
  
          Notes
          -----
          Further arguments and keywords are passed directly to
          `ChemicalEquation.to_series`.
  
          Examples
          --------
          >>> from pyrrole import ChemicalSystem
          >>> from pyrrole.atoms import create_data, read_cclib
          >>> data = create_data(
          ...     read_cclib("data/acetate/acetic_acid.out", "AcOH(g)"),
          ...     read_cclib("data/acetate/acetic_acid@water.out", "AcOH(aq)"))
          >>> equilibrium = ChemicalSystem("AcOH(g) <=> AcOH(aq)", data)
          >>> digraph = equilibrium.to_digraph()
          >>> sorted(digraph.nodes(data='freeenergy'))
          [('AcOH(aq)', -228.57526805), ('AcOH(g)', -228.56450866)]
          >>> digraph.number_of_nodes()
          2
          >>> digraph.number_of_edges()
          2
  
          """; 16, assignment; 17, identifier:equation; 18, attribute; 19, block; 20, identifier:digraph; 21, identifier:digraph; 22, call; 23, identifier:self; 24, identifier:equations; 25, expression_statement; 26, try_statement; 27, expression_statement; 28, try_statement; 29, expression_statement; 30, try_statement; 31, expression_statement; 32, if_statement; 33, attribute; 34, argument_list; 35, assignment; 36, block; 37, except_clause; 38, call; 39, block; 40, except_clause; 41, call; 42, block; 43, except_clause; 44, call; 45, comparison_operator:arrow == '<=>'; 46, block; 47, identifier:_nx; 48, identifier:DiGraph; 49, pattern_list; 50, list_comprehension; 51, expression_statement; 52, identifier:ValueError; 53, block; 54, attribute; 55, argument_list; 56, expression_statement; 57, identifier:ValueError; 58, block; 59, attribute; 60, argument_list; 61, expression_statement; 62, identifier:ValueError; 63, block; 64, attribute; 65, argument_list; 66, identifier:arrow; 67, string; 68, expression_statement; 69, identifier:reactants; 70, identifier:arrow; 71, identifier:products; 72, call; 73, for_in_clause; 74, assignment; 75, expression_statement; 76, identifier:digraph; 77, identifier:add_node; 78, identifier:reactants; 79, dictionary_splat; 80, assignment; 81, expression_statement; 82, identifier:digraph; 83, identifier:add_node; 84, identifier:products; 85, dictionary_splat; 86, assignment; 87, expression_statement; 88, identifier:digraph; 89, identifier:add_edge; 90, identifier:reactants; 91, identifier:products; 92, dictionary_splat; 93, string_content:<=>; 94, call; 95, attribute; 96, argument_list; 97, identifier:value; 98, call; 99, identifier:attr; 100, call; 101, assignment; 102, identifier:attr; 103, identifier:attr; 104, call; 105, assignment; 106, identifier:attr; 107, identifier:attr; 108, call; 109, assignment; 110, identifier:attr; 111, attribute; 112, argument_list; 113, identifier:value; 114, identifier:strip; 115, identifier:_split_arrows; 116, argument_list; 117, attribute; 118, argument_list; 119, identifier:attr; 120, call; 121, attribute; 122, argument_list; 123, identifier:attr; 124, call; 125, attribute; 126, argument_list; 127, identifier:attr; 128, call; 129, identifier:digraph; 130, identifier:add_edge; 131, identifier:products; 132, identifier:reactants; 133, dictionary_splat; 134, call; 135, call; 136, identifier:to_dict; 137, identifier:dict; 138, argument_list; 139, call; 140, identifier:to_dict; 141, identifier:dict; 142, argument_list; 143, call; 144, identifier:to_dict; 145, identifier:dict; 146, argument_list; 147, identifier:attr; 148, identifier:str; 149, argument_list; 150, attribute; 151, argument_list; 152, attribute; 153, argument_list; 154, attribute; 155, argument_list; 156, identifier:equation; 157, identifier:equation; 158, identifier:to_series; 159, string:"reactants"; 160, list_splat; 161, dictionary_splat; 162, identifier:equation; 163, identifier:to_series; 164, string:"products"; 165, list_splat; 166, dictionary_splat; 167, identifier:equation; 168, identifier:to_series; 169, list_splat; 170, dictionary_splat; 171, identifier:args; 172, identifier:kwargs; 173, identifier:args; 174, identifier:kwargs; 175, identifier:args; 176, identifier:kwargs
code: def to_digraph(self, *args, **kwargs):
          """
          Compute a directed graph for the chemical system.
  
          Returns
          -------
          digraph : `networkx.DiGraph`
              Graph nodes are reactants and/or products of chemical equations,
              while edges represent the equations themselves. Double ended edges
              are used to represent equilibria. Attributes are computed with
              `ChemicalEquation.to_series` for each equation (see examples
              below).
  
          Notes
          -----
          Further arguments and keywords are passed directly to
          `ChemicalEquation.to_series`.
  
          Examples
          --------
          >>> from pyrrole import ChemicalSystem
          >>> from pyrrole.atoms import create_data, read_cclib
          >>> data = create_data(
          ...     read_cclib("data/acetate/acetic_acid.out", "AcOH(g)"),
          ...     read_cclib("data/acetate/acetic_acid@water.out", "AcOH(aq)"))
          >>> equilibrium = ChemicalSystem("AcOH(g) <=> AcOH(aq)", data)
          >>> digraph = equilibrium.to_digraph()
          >>> sorted(digraph.nodes(data='freeenergy'))
          [('AcOH(aq)', -228.57526805), ('AcOH(g)', -228.56450866)]
          >>> digraph.number_of_nodes()
          2
          >>> digraph.number_of_edges()
          2
  
          """
          # TODO: make test for this
          digraph = _nx.DiGraph()
          for equation in self.equations:
              reactants, arrow, products = [value.strip() for value
                                            in _split_arrows(str(equation))]
  
              try:
                  attr = equation.to_series("reactants", *args,
                                            **kwargs).to_dict()
              except ValueError:
                  attr = dict()
              digraph.add_node(reactants, **attr)
  
              try:
                  attr = equation.to_series("products", *args,
                                            **kwargs).to_dict()
              except ValueError:
                  attr = dict()
              digraph.add_node(products, **attr)
  
              try:
                  attr = equation.to_series(*args, **kwargs).to_dict()
              except ValueError:
                  attr = dict()
              digraph.add_edge(reactants, products, **attr)
              if arrow == '<=>':
                  digraph.add_edge(products, reactants, **attr)
  
          return digraph