Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to add clusters together with edges? #452

Open
jonnyhoff opened this issue Jan 29, 2021 · 3 comments
Open

Is there a way to add clusters together with edges? #452

jonnyhoff opened this issue Jan 29, 2021 · 3 comments

Comments

@jonnyhoff
Copy link

Example:

    with Cluster("Cluster 1") as cluster1:
        c1node1 = VM("c1node1")

    with Cluster("Cluster 2") as cluster2:
        c2node1 = VM("c2node1")

    cluster1 - Edge(color="red") - cluster2
@clayms
Copy link

clayms commented Jan 31, 2021

Not that way.

To get this effect you will have to put an Edge from a Node in one Cluster to a Node in the second Cluster and use the ltail (logical tail of Edge) and lhead (logical head of Edge) options of the Edge .

See the issue comments:

  1. Is there a way to have arrows to and from Clusters #17 (comment)
  2. Is there a way to have arrows to and from Clusters #17 (comment)

Also see example below.
Note:

  1. the graph_attr must include "compound":"true" and "splines":"spline" for this to work.
  2. you must prefix the reference to each Cluster name with "cluster_" in the ltail and lhead Edge attributes.
from diagrams import Diagram, Cluster, Edge
from diagrams.oci.compute import VM

graph_attr = {
    "layout":"dot",
    "compound":"true",
    "splines":"spline",
    }

with Diagram("cluster to cluster edge", graph_attr=graph_attr, show=False) as diag:

    with Cluster("Cluster 1"):
        c1node1 = VM("c1node1")

    with Cluster("Cluster 2"):
        c2node1 = VM("c2node1")

    c1node1 - Edge(color="red", ltail="cluster_Cluster 1", lhead="cluster_Cluster 2") - c2node1

diag

image

@chadfurman
Copy link

there might be a way, eventually, to make a PR that can allow shifting between clusters. Here we see that it's possible to create edges between clusters natively in graphviz https://graphviz.readthedocs.io/en/stable/examples.html#fdpclust-py

@chadfurman
Copy link

looks like there's a long-running discussion here: #17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants