text
stringlengths
0
828
out_edges[referrer].append(edge)
in_edges[referent].append(edge)
return cls._raw(
vertices=vertices,
edges=edges,
out_edges=out_edges,
in_edges=in_edges,
head=head,
tail=tail,
)"
1106,"def annotated(self):
""""""
Annotate this graph, returning an AnnotatedGraph object
with the same structure.
""""""
# Build up dictionary of edge annotations.
edge_annotations = {}
for edge in self.edges:
if edge not in edge_annotations:
# We annotate all edges from a given object at once.
referrer = self._tail[edge]
known_refs = annotated_references(referrer)
for out_edge in self._out_edges[referrer]:
referent = self._head[out_edge]
if known_refs[referent]:
annotation = known_refs[referent].pop()
else:
annotation = None
edge_annotations[out_edge] = annotation
annotated_vertices = [
AnnotatedVertex(
id=id(vertex),
annotation=object_annotation(vertex),
)
for vertex in self.vertices
]
annotated_edges = [
AnnotatedEdge(
id=edge,
annotation=edge_annotations[edge],
head=id(self._head[edge]),
tail=id(self._tail[edge]),
)
for edge in self.edges
]
return AnnotatedGraph(
vertices=annotated_vertices,
edges=annotated_edges,
)"
1107,"def export_image(self, filename='refcycle.png', format=None,
dot_executable='dot'):
""""""
Export graph as an image.
This requires that Graphviz is installed and that the ``dot``
executable is in your path.
The *filename* argument specifies the output filename.
The *format* argument lets you specify the output format. It may be
any format that ``dot`` understands, including extended format
specifications like ``png:cairo``. If omitted, the filename extension
will be used; if no filename extension is present, ``png`` will be
used.
The *dot_executable* argument lets you provide a full path to the
``dot`` executable if necessary.
""""""
return self.annotated().export_image(
filename=filename,
format=format,
dot_executable=dot_executable,
)"
1108,"def owned_objects(self):
""""""
List of gc-tracked objects owned by this ObjectGraph instance.
""""""
return (
[
self,
self.__dict__,
self._head,
self._tail,
self._out_edges,
self._out_edges._keys,
self._out_edges._values,
self._in_edges,
self._in_edges._keys,
self._in_edges._values,
self._vertices,
self._vertices._elements,
self._edges,
] +