def from_json(cls, json_graph):
        """
        Reconstruct the graph from a graph exported to JSON.

        """
        obj = json.loads(json_graph)

        vertices = [
            AnnotatedVertex(
                id=vertex["id"],
                annotation=vertex["annotation"],
            )
            for vertex in obj["vertices"]
        ]

        edges = [
            AnnotatedEdge(
                id=edge["id"],
                annotation=edge["annotation"],
                head=edge["head"],
                tail=edge["tail"],
            )
            for edge in obj["edges"]
        ]

        return cls(vertices=vertices, edges=edges)
def from_json ( cls , json_graph ) : obj = json . loads ( json_graph ) vertices = [ AnnotatedVertex ( id = vertex [ "id" ] , annotation = vertex [ "annotation" ] , ) for vertex in obj [ "vertices" ] ] edges = [ AnnotatedEdge ( id = edge [ "id" ] , annotation = edge [ "annotation" ] , head = edge [ "head" ] , tail = edge [ "tail" ] , ) for edge in obj [ "edges" ] ] return cls ( vertices = vertices , edges = edges )
Reconstruct the graph from a graph exported to JSON.