if self._graph.has_edge(knowledge_triple.subject, knowledge_triple.object_):
            self._graph.remove_edge(knowledge_triple.subject, knowledge_triple.object_)
[docs]    def get_triples(self) -> List[Tuple[str, str, str]]:
        """Get all triples in the graph."""
        return [(u, v, d["relation"]) for u, v, d in self._graph.edges(data=True)]
[docs]    def get_entity_knowledge(self, entity: str, depth: int = 1) -> List[str]:
        """Get information about an entity."""
        import networkx as nx
        # TODO: Have more information-specific retrieval methods
        if not self._graph.has_node(entity):
            return []
        results = []
        for src, sink in nx.dfs_edges(self._graph, entity, depth_limit=depth):
            relation = self._graph[src][sink]["relation"]
            results.append(f"{src} {relation} {sink}")
        return results
[docs]    def write_to_gml(self, path: str) -> None:
        import networkx as nx
        nx.write_gml(self._graph, path)
[docs]    def clear(self) -> None:
        """Clear the graph."""
        self._graph.clear()
[docs]    def get_topological_sort(self) -> List[str]:
        """Get a list of entity names in the graph sorted by causal dependence."""
        import networkx as nx
        return list(nx.topological_sort(self._graph))
[docs]    def draw_graphviz(self, **kwargs: Any) -> None:
        """
        Provides better drawing
        Usage in a jupyter notebook:
            >>> from IPython.display import SVG