Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions examples/benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! This is a sample program that prints a bunch of elements to an SVG file so
//! we can visually see if the things that we render look right.

use layout::adt::dag::SubgraphHandle;
use layout::backends::svg::SVGWriter;
use layout::core::base::Orientation;
use layout::core::color::Color;
Expand All @@ -10,7 +11,15 @@ pub const LAYOUT_HELPER: bool = true;

fn test_main(n_node: usize, _n_edge: usize) {
let mut svg = SVGWriter::new();
let mut gb = VisualGraph::new(Orientation::LeftToRight);
let mut gb = VisualGraph::new(
Orientation::LeftToRight,
Element::create(
ShapeKind::Frame(Some("Main Graph".to_string())),
StyleAttr::new(Color::transparent(), 0, None, 0, 0),
Orientation::LeftToRight,
Point::zero(),
),
);

for i in 0..n_node {
let elem = Element::create(
Expand All @@ -19,7 +28,7 @@ fn test_main(n_node: usize, _n_edge: usize) {
Orientation::LeftToRight,
Point::zero(),
);
gb.add_node(elem);
gb.add_node(elem, SubgraphHandle::new(0));
}
let t0 = std::time::Instant::now();

Expand Down
28 changes: 28 additions & 0 deletions inputs/cluster_1.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
digraph G {
subgraph cluster_0 {
B -> I -> P
B -> K -> S
A
C
}

subgraph cluster_1 {
E -> H -> T
M
}

subgraph cluster_2 {
D
G -> J
N Q
}
A -> L -> U
K -> O
N -> T
D -> M -> Q
F -> N
J -> R
C -> H


}
32 changes: 32 additions & 0 deletions inputs/cluster_2.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
digraph G {
subgraph cluster_0 {
B -> I -> P
B -> K -> S
A
C
}

subgraph cluster_1 {
E -> H -> T
M
}

subgraph cluster_2 {
D
G -> J
N Q

subgraph cluster_3 {
Y -> Z
}
}
A -> L -> U
K -> O
N -> T
D -> M -> Q
F -> N
J -> R
C -> H
C -> Z

}
22 changes: 22 additions & 0 deletions inputs/comment_tab.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
digraph G {

subgraph cluster_0 {
style=filled;
color=lightgrey;
node [style=filled,color=white];
a0 -> a1 -> a2 -> a3;
label = "process #1";
}


start -> a0;
start -> b0;
// a1 -> b3;
// b2 -> a3;
a3 -> a0;
a3 -> end;
b3 -> end;

start [shape=Mdiamond];
end [shape=Msquare];
}
212 changes: 212 additions & 0 deletions inputs/complex_nested.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
digraph ComplexSystem {
// Global graph settings
graph [fontname="Helvetica" fontsize=12 compound=true shape=circle];
node [fontname="Helvetica" fontsize=10 shape=box style=filled];
edge [fontname="Helvetica" fontsize=9];

// Main title
labelloc=t;
fontsize=16;

// Frontend Layer
subgraph cluster_frontend {
style=filled;
color=lightblue;
fillcolor="#e6f3ff";

// Web Application cluster
subgraph cluster_web {
label="Web Application";
style=filled;
fillcolor="#cce5ff";

subgraph cluster_ui {
label="UI Components";
style=filled;
fillcolor="#b3d9ff";

ui_login [label="Login\nComponent" fillcolor="#99ccff"];
ui_dashboard [label="Dashboard\nComponent" fillcolor="#99ccff"];
ui_reports [label="Reports\nComponent" fillcolor="#99ccff"];
}

subgraph cluster_state {
label="State Management";
style=filled;
fillcolor="#b3d9ff";

state_store [label="Redux Store" fillcolor="#99ccff"];
state_actions [label="Actions" fillcolor="#99ccff"];
state_reducers [label="Reducers" fillcolor="#99ccff"];
}
}

// Mobile Application cluster
subgraph cluster_mobile {
label="Mobile Application";
style=filled;
fillcolor="#cce5ff";

mobile_ios [label="iOS App" fillcolor="#99ccff"];
mobile_android [label="Android App" fillcolor="#99ccff"];
mobile_shared [label="Shared Logic" fillcolor="#99ccff"];
}
}

// Backend Layer
subgraph cluster_backend {
label="Backend Layer";
style=filled;
color=lightcoral;
fillcolor="#ffe6e6";

// API Gateway
subgraph cluster_gateway {
label="API Gateway";
style=filled;
fillcolor="#ffcccc";

gw_auth [label="Authentication" fillcolor="#ffb3b3"];
gw_routing [label="Request Routing" fillcolor="#ffb3b3"];
gw_ratelimit [label="Rate Limiting" fillcolor="#ffb3b3"];
}

gw_auth -> A -> B

// Microservices
subgraph cluster_services {
label="Microservices";
style=filled;
fillcolor="#ffcccc";

subgraph cluster_user_service {
label="User Service";
style=filled;
fillcolor="#ffb3b3";

user_api [label="User API" fillcolor="#ff9999"];
user_logic [label="Business Logic" fillcolor="#ff9999"];
user_validation [label="Validation" fillcolor="#ff9999"];
}

subgraph cluster_order_service {
label="Order Service";
style=filled;
fillcolor="#ffb3b3";

order_api [label="Order API" fillcolor="#ff9999"];
order_logic [label="Business Logic" fillcolor="#ff9999"];
order_payment [label="Payment Handler" fillcolor="#ff9999"];
}

subgraph cluster_inventory_service {
label="Inventory Service";
style=filled;
fillcolor="#ffb3b3";

inv_api [label="Inventory API" fillcolor="#ff9999"];
inv_logic [label="Stock Management" fillcolor="#ff9999"];
inv_alerts [label="Alert System" fillcolor="#ff9999"];
}
}
}

// Data Layer
subgraph cluster_data {
label="Data Layer";
style=filled;
color=lightgreen;
fillcolor="#e6ffe6";

subgraph cluster_databases {
label="Databases";
style=filled;
fillcolor="#ccffcc";

db_users [label="Users DB\n(PostgreSQL)" shape=cylinder fillcolor="#b3ffb3"];
db_orders [label="Orders DB\n(PostgreSQL)" shape=cylinder fillcolor="#b3ffb3"];
db_inventory [label="Inventory DB\n(MongoDB)" shape=cylinder fillcolor="#b3ffb3"];
}

subgraph cluster_cache {
label="Cache Layer";
style=filled;
fillcolor="#ccffcc";

cache_redis [label="Redis Cache" shape=cylinder fillcolor="#b3ffb3"];
cache_sessions [label="Session Store" shape=cylinder fillcolor="#b3ffb3"];
}

subgraph cluster_messaging {
label="Message Queue";
style=filled;
fillcolor="#ccffcc";

mq_events [label="Event Bus\n(RabbitMQ)" shape=parallelogram fillcolor="#b3ffb3"];
mq_jobs [label="Job Queue" shape=parallelogram fillcolor="#b3ffb3"];
}
}

// External Services
subgraph cluster_external {
label="External Services";
style=filled;
color=lightyellow;
fillcolor="#fffacd";

ext_payment [label="Payment Gateway" fillcolor="#ffec8b"];
ext_email [label="Email Service" fillcolor="#ffec8b"];
ext_analytics [label="Analytics" fillcolor="#ffec8b"];
}

// Frontend connections
ui_login -> state_actions;
ui_dashboard -> state_store;
ui_reports -> state_store;
state_actions -> state_reducers;
state_reducers -> state_store;

mobile_ios -> mobile_shared;
mobile_android -> mobile_shared;

// Frontend to Gateway connections (using compound for cluster edges)
state_store -> gw_routing [ltail=cluster_web lhead=cluster_gateway label="HTTPS"];
mobile_shared -> gw_routing [ltail=cluster_mobile lhead=cluster_gateway label="HTTPS"];

// Gateway to Services
gw_auth -> user_api [lhead=cluster_user_service];
gw_routing -> order_api [lhead=cluster_order_service];
gw_routing -> inv_api [lhead=cluster_inventory_service];
gw_ratelimit -> gw_routing;

// Service internal flows
user_api -> user_logic -> user_validation;
order_api -> order_logic -> order_payment;
inv_api -> inv_logic -> inv_alerts;

// Services to Data Layer
user_logic -> db_users;
order_logic -> db_orders;
inv_logic -> db_inventory;

user_logic -> cache_redis [label="cache"];
order_logic -> cache_sessions [label="session"];

// Messaging connections
order_logic -> mq_events [label="publish\nevents"];
inv_logic -> mq_events [label="subscribe"];
order_payment -> mq_jobs [label="async jobs"];

// Service to External
order_payment -> ext_payment [label="process\npayment"];
user_logic -> ext_email [label="notifications"];
gw_routing -> ext_analytics [ltail=cluster_gateway label="metrics"];

// Cross-service communication
order_logic -> inv_api [label="check stock" style=dashed color=blue];
inv_logic -> order_api [label="update status" style=dashed color=blue];

db_orders -> cache_redis


}
Loading
Loading