-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move and update last new release note
- Loading branch information
Showing
2 changed files
with
68 additions
and
6 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
releasenotes/notes/0.9.0/simple-layouts-93db8f7f5fa1fe83.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
features: | ||
- | | ||
Four simple layout functions were added: | ||
* :func:`~retworkx.bipartite_layout` | ||
* :func:`~retworkx.circular_layout` | ||
* :func:`~retworkx.shell_layout` | ||
* :func:`~retworkx.spiral_layout` | ||
These can be used to adjust the layout used in visualizations, for example: | ||
.. jupyter-execute:: | ||
import retworkx | ||
from retworkx.visualization import mpl_draw | ||
graph = retworkx.generators.path_graph(weights=list(range(24))) | ||
layout = retworkx.bipartite_layout(graph, set(range(12))) | ||
mpl_draw(graph, pos=layout) | ||
.. jupyter-execute:: | ||
import retworkx | ||
from retworkx.visualization import mpl_draw | ||
graph = retworkx.generators.path_graph(weights=list(range(24))) | ||
layout = retworkx.circular_layout(graph) | ||
mpl_draw(graph, pos=layout) | ||
.. jupyter-execute:: | ||
import retworkx | ||
from retworkx.visualization import mpl_draw | ||
graph = retworkx.generators.star_graph(25) | ||
layout = retworkx.shell_layout(graph) | ||
mpl_draw(graph, pos=layout) | ||
.. jupyter-execute:: | ||
import retworkx | ||
from retworkx.visualization import mpl_draw | ||
graph = retworkx.generators.path_graph(weights=list(range(24))) | ||
layout = retworkx.spiral_layout(graph) | ||
mpl_draw(graph, pos=layout) | ||
Or with the :func:`~retworkx.visualization.graphviz_drawer` function: | ||
.. jupyter-execute:: | ||
import retworkx | ||
from retworkx.visualization import graphviz_draw | ||
graph = retworkx.generators.path_graph(weights=list(range(24))) | ||
layout = retworkx.spiral_layout(graph) | ||
def node_attr_fn(node): | ||
point = layout[node] | ||
return { | ||
"shape": "circle", | ||
"pos": '"%s,%s!"' % (point[0], point[1]), | ||
"fillcolor": "yellow", | ||
"style": "filled", | ||
} | ||
graphviz_draw(graph, node_attr_fn=node_attr_fn, method='fdp') |
This file was deleted.
Oops, something went wrong.