-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
52 additions
and
4 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,13 +1,61 @@ | ||
namespace ISADotNet.Viz | ||
|
||
open ISADotNet | ||
open ISADotNet.API | ||
open Cyjs.NET | ||
|
||
module DAG = | ||
type DAG = | ||
|
||
let show (dag : CyGraph.CyGraph) = CyGraph.show dag | ||
static member show (dag : CyGraph.CyGraph) = CyGraph.show dag | ||
|
||
let toEmbeddedHTML (dag : CyGraph.CyGraph) = HTML.toEmbeddedHTML dag | ||
static member toEmbeddedHTML (dag : CyGraph.CyGraph) = HTML.toEmbeddedHTML dag | ||
|
||
let toHTML (dag : CyGraph.CyGraph) = HTML.toCytoHTML dag | ||
static member toHTML (dag : CyGraph.CyGraph) = HTML.toCytoHTML dag | ||
|
||
static member fromProcessSequence (ps : Process list, ?Schema : Schema) = | ||
|
||
let schema = Option.defaultValue ISADotNet.Viz.Schema.DefaultGrey Schema | ||
|
||
let edges = | ||
ps | ||
|> List.collect (fun p -> | ||
p.Outputs.Value | ||
|> List.zip p.Inputs.Value | ||
|> List.map (fun (i,o) -> ProcessInput.getName i |> Option.get,ProcessOutput.getName o |> Option.get,p.Name.Value) | ||
) | ||
|
||
let cyNodes = | ||
edges | ||
|> List.collect (fun (i,o,e) -> [i;o]) | ||
|> List.distinct | ||
|> List.map (fun n -> node n [CyParam.label n]) | ||
|
||
let cyEgdes = | ||
edges | ||
|> List.mapi (fun index (i,o,e) -> edge (string index) i o [CyParam.label e]) | ||
|
||
CyGraph.initEmpty () | ||
|> CyGraph.withElements cyNodes | ||
|> CyGraph.withElements cyEgdes | ||
|> CyGraph.withStyle "node" | ||
[ | ||
CyParam.content =. CyParam.label | ||
CyParam.color schema.VertexLabelColor | ||
CyParam.Background.color schema.VertexColor | ||
] | ||
|> CyGraph.withStyle "edge" | ||
[ | ||
CyParam.content =. CyParam.label | ||
CyParam.Curve.style "bezier" | ||
CyParam.opacity 0.666 | ||
CyParam.width 7 | ||
CyParam.Target.Arrow.shape "triangle" | ||
CyParam.Source.Arrow.shape "circle" | ||
|
||
CyParam.color schema.EdgeLabelColor | ||
CyParam.Line.color schema.EdgeColor | ||
CyParam.Target.Arrow.color schema.EdgeColor | ||
CyParam.Source.Arrow.color schema.EdgeColor | ||
] | ||
|> CyGraph.withLayout (Layout.initBreadthfirst id) | ||
|> CyGraph.withSize(800, 400) |