A StructureGraph object describing bonding information
        in the crystal. Lazily constructed.

        :param edge_weight: a value to store on the Graph edges,
        by default this is "bond_length" but other supported
        values are any of the attributes of CriticalPoint
        :return:

def structure_graph(self, edge_weight="bond_length", edge_weight_units="Å"):
        """
        A StructureGraph object describing bonding information
        in the crystal. Lazily constructed.

        :param edge_weight: a value to store on the Graph edges,
        by default this is "bond_length" but other supported
        values are any of the attributes of CriticalPoint
        :return:
        """

        sg = StructureGraph.with_empty_graph(self.structure, name="bonds",
                                             edge_weight_name=edge_weight,
                                             edge_weight_units=edge_weight_units)

        edges = self.edges.copy()
        idx_to_delete = []
        # check for duplicate bonds
        for idx, edge in edges.items():
            unique_idx = self.nodes[idx]['unique_idx']
            # only check edges representing bonds, not rings
            if self.critical_points[unique_idx].type == CriticalPointType.bond:
                if idx not in idx_to_delete:
                    for idx2, edge2 in edges.items():
                        if idx != idx2 and edge == edge2:
                            idx_to_delete.append(idx2)
                            warnings.warn("Duplicate edge detected, try re-running "
                                          "critic2 with custom parameters to fix this. "
                                          "Mostly harmless unless user is also "
                                          "interested in rings/cages.")
                            logger.debug("Duplicate edge between points {} (unique point {})"
                                         "and {} ({}).".format(idx, self.nodes[idx]['unique_idx'],
                                                               idx2, self.nodes[idx2]['unique_idx']))
        # and remove any duplicate bonds present
        for idx in idx_to_delete:
            del edges[idx]

        for idx, edge in edges.items():
            unique_idx = self.nodes[idx]['unique_idx']
            # only add edges representing bonds, not rings
            if self.critical_points[unique_idx].type == CriticalPointType.bond:

                from_idx = edge['from_idx']
                to_idx = edge['to_idx']

                from_lvec = edge['from_lvec']
                to_lvec = edge['to_lvec']

                relative_lvec = np.subtract(to_lvec, from_lvec)

                if edge_weight == "bond_length":
                    weight = self.structure.get_distance(from_idx, to_idx, jimage=relative_lvec)
                else:
                    weight = getattr(self.critical_points[unique_idx],
                                     edge_weight, None)

                sg.add_edge(from_idx, to_idx,
                            from_jimage=from_lvec, to_jimage=to_lvec,
                            weight=weight)

        return sg