def with_edges(molecule, edges):
        """
        Constructor for MoleculeGraph, using pre-existing or pre-defined edges
        with optional edge parameters.

        :param molecule: Molecule object
        :param edges: dict representing the bonds of the functional
                group (format: {(u, v): props}, where props is a dictionary of
                properties, including weight. Props should be None if no
                additional properties are to be specified.
        :return: mg, a MoleculeGraph
        """

        mg = MoleculeGraph.with_empty_graph(molecule, name="bonds",
                                            edge_weight_name="weight",
                                            edge_weight_units="")

        for edge, props in edges.items():

            try:
                from_index = edge[0]
                to_index = edge[1]
            except TypeError:
                raise ValueError("Edges must be given as (from_index, to_index)"
                                 "tuples")

            if props is not None:
                if "weight" in props.keys():
                    weight = props["weight"]
                    del props["weight"]
                else:
                    weight = None

                if len(props.items()) == 0:
                    props = None
            else:
                weight = None

            nodes = mg.graph.nodes
            if not (from_index in nodes and to_index in nodes):
                raise ValueError("Edges cannot be added if nodes are not"
                                 " present in the graph. Please check your"
                                 " indices.")

            mg.add_edge(from_index, to_index, weight=weight,
                        edge_properties=props)

        mg.set_node_attributes()
        return mg
Constructor for MoleculeGraph, using pre-existing or pre-defined edges
        with optional edge parameters.

        :param molecule: Molecule object
        :param edges: dict representing the bonds of the functional
                group (format: {(u, v): props}, where props is a dictionary of
                properties, including weight. Props should be None if no
                additional properties are to be specified.
        :return: mg, a MoleculeGraph