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
Create Subgraph/cluster with version 0.9.2 #257
Comments
Thx @rich-iannone for the great package; I think the importance of programmatically generating DAG's and similar graphs from dataframes cannot be understated. In regards to this issue, I am wondering if there is any guidance on @Enchufa2 's comment/inquiry. Can the "subgraph cluster_X" capabilities be replicated using |
@flyaflya if I recall correctly, there is some capability to bundle/coalesce nodes together (I think by using the Could you provide a concrete example of what you’d like to achieve from inputs to output? Should the functionality not be available, I’d be more than happy to include it into the package as a new feature. |
I see: library(DiagrammeR)
create_node_df(n=4, label=TRUE, cluster=rep(c("A", "B"), 2)) %>%
create_graph() %>%
set_global_graph_attrs("layout", "dot", "graph") %>%
render_graph()
#> Error: `replacement` must be a character vector Not a very helpful message, BTW. |
@rich-iannone, thanks for the follow-up. As a simple example, I would like to reproduce the output of this code:
The code I would like to use is something like this:
, but I get the same error as @Enchufa2 (i.e. Thanks for any help/guidance/new features/etc. I would love to make this tool my default over using tikz. |
+1 for this - essential / critical for me |
also, sounds like DiagrammeR should support nested subgraphs too? (but obviously this won't work if ordinary subgraphs don't work) |
@Enchufa2 I tracked down this bug to line 499 of the file I can not fix it, since I do not really get what should happen here. @rich-iannone This bug was there in the first version of the file. Even the indentation gives away, that something is wrong. Unfortunately there is no unit test for |
@tvarju Good catch! But it's not a simple syntax error. That code is supposed to strip out nodes from the |
@stevepowell99 nested subraphs with a dot notation syntax like I could implement it right now. A more extended support with cluster attributes (like label positioning in the example of @flyaflya ) |
@tvarju sounds promising! I am so eager for clusters to happen! Sure, there are design decisions .... how to introduce 1) global cluster attributes and 2) cluster-by-cluster attributes and 3) information on the cluster hierarchy? The way you suggest sounds fine for 3 but doesn't help with 1 or 2. 1 and 2 could be achieved with
without having a separate mechanism for clusters like the one for nodes and edges, which might be overkill |
Thanks @tvarju for the PR and everyone else in this issue. The PR is now merged :) |
Thanks @tvarju and @rich-iannone ! Could you give a quick example how this can now be used to create a graph? I can run the @flyaflya https://github.com/rich-iannone/DiagrammeR/issues/257#issuecomment-357470193 which now does not crash but produces this: |
You need to add "dot" to the layout attribute, but still, similar issue: nodeDF = data.frame(id = c(1,2,3),
label = c("a","b","c"),
cluster = c(NA,"data","data"))
edgeDF = data.frame(from = c(1,2),
to = c(3,3))
create_graph() %>%
add_nodes_from_table(nodeDF, label_col = label) %>%
add_edges_from_table(edgeDF, from, to, id_external) %>%
add_global_graph_attrs("layout", "dot", "graph") %>%
render_graph() The implementation needs refinement and more test cases, because there are problems with edges. |
@Enchufa2 My bad. Did not notice that another part of the code is also messing with the cluster attribute. My unit test did not catch it. Your example is now one of the unit tests, and the fix is in the PR. |
Thanks @tvarju @rich-iannone @Enchufa2 ... so this does not include the suggested dot notation for nested clusters? This doesn't produce nested clusters:
|
@stevepowell99 no, it does not implement the dot notation, as you have written in a previous comment it would only solve 1 of the three requirements. I think as this issue is closed now it is time to open a new one for that discussion. Keep the issue tracker tidy, one issue per thread. |
Thanks @tvarju @rich-iannone and @Enchufa2 ! This is great. The cluster label placement is also changeable via: Here is a pic of an example I made: |
I have implemented nested clusters by creating a clusters_df dataframe with the following structure:
where graph, node and edge are lists of named lists with each named list representing I then changed the cluster section of generate_dot.R to be the following:
This is a bit ugly, but if you don't mind the approach I could try submitting a PR. |
hi, can u showme how this map looks in an image:
|
Hello,
are cluster/subgraph supported in version 0.9.2 of DiagrameR?
Thanks
The text was updated successfully, but these errors were encountered: