11/* Functions used to output query graphs as [graphviz dot](https://graphviz.org/doc/info/lang.html) outputs. */
22
33import { simpleTraversal , Edge , QueryGraph , QueryGraphState , Vertex } from "./querygraph" ;
4- import { attribute , Digraph , digraph , ICluster , IEdge , INode , toDot as graphvizToDot } from 'ts-graphviz' ;
4+ import { attribute , digraph , RootGraphModel , GraphBaseModel , EdgeModel , NodeModel , toDot as graphvizToDot } from 'ts-graphviz' ;
55import { RootPath , traversePath } from "./graphPath" ;
66
7- function setDefaultGraphAttributes ( _ : Digraph ) {
7+ function setDefaultGraphAttributes ( _ : RootGraphModel ) {
88 //vizGraph.attributes.edge.set(attribute.labelfloat, true);
99}
1010
@@ -33,7 +33,7 @@ export function groupToDot(
3333 return graphvizToDot ( vizGraph ) ;
3434}
3535
36- function addToVizGraphAndHighlight ( graph : QueryGraph , vizGraph : ICluster , config ?: DotGraphConfig ) {
36+ function addToVizGraphAndHighlight ( graph : QueryGraph , vizGraph : GraphBaseModel , config ?: DotGraphConfig ) {
3737 const state = addToVizGraph ( graph , vizGraph , config ?. noTerminal ) ;
3838 highlightPaths ( state , config ?. highlightedPaths ) ;
3939}
@@ -64,7 +64,7 @@ type HighlitedPath = {
6464 color : string
6565}
6666
67- function addToVizGraph ( graph : QueryGraph , vizGraph : ICluster , noTerminal : boolean = false ) : QueryGraphState < INode , IEdge > {
67+ function addToVizGraph ( graph : QueryGraph , vizGraph : GraphBaseModel , noTerminal : boolean = false ) : QueryGraphState < NodeModel , EdgeModel > {
6868 const vizSubGraphs = new Map ( ) ;
6969 for ( const source of graph . sources . keys ( ) ) {
7070 if ( source != graph . name ) {
@@ -76,12 +76,12 @@ function addToVizGraph(graph: QueryGraph, vizGraph: ICluster, noTerminal: boolea
7676 } ) ) ;
7777 }
7878 }
79- const getNode = function ( vertex : Vertex ) : INode {
79+ const getNode = function ( vertex : Vertex ) : NodeModel {
8080 const existingNode = state . getVertexState ( vertex ) ;
8181 if ( existingNode ) {
8282 return existingNode ;
8383 }
84- let newNode : INode ;
84+ let newNode : NodeModel ;
8585 if ( vertex . source == graph . name ) {
8686 newNode = vizGraph . createNode ( vertex . type . name ) ;
8787 } else {
@@ -94,13 +94,13 @@ function addToVizGraph(graph: QueryGraph, vizGraph: ICluster, noTerminal: boolea
9494 state . setVertexState ( vertex , newNode ) ;
9595 return newNode ;
9696 }
97- const pickGraphForEdge = function ( head : Vertex , tail : Vertex ) : ICluster {
97+ const pickGraphForEdge = function ( head : Vertex , tail : Vertex ) : GraphBaseModel {
9898 if ( head . source == tail . source && head . source != graph . name ) {
9999 return vizSubGraphs . get ( head . source ) ;
100100 }
101101 return vizGraph ;
102102 }
103- const state = new QueryGraphState < INode , IEdge > ( graph ) ;
103+ const state = new QueryGraphState < NodeModel , EdgeModel > ( graph ) ;
104104 const onEdge = function ( edge : Edge ) : boolean {
105105 const head = edge . head ;
106106 const tail = edge . tail ;
@@ -119,11 +119,11 @@ function addToVizGraph(graph: QueryGraph, vizGraph: ICluster, noTerminal: boolea
119119 return state ;
120120}
121121
122- function highlightPaths ( state : QueryGraphState < INode , IEdge > , toHighlights ?: HighlitedPath [ ] ) {
122+ function highlightPaths ( state : QueryGraphState < NodeModel , EdgeModel > , toHighlights ?: HighlitedPath [ ] ) {
123123 toHighlights ?. forEach ( h => highlightPath ( state , h ) ) ;
124124}
125125
126- function highlightPath ( state : QueryGraphState < INode , IEdge > , toHighlight : HighlitedPath ) {
126+ function highlightPath ( state : QueryGraphState < NodeModel , EdgeModel > , toHighlight : HighlitedPath ) {
127127 traversePath ( toHighlight . path , e => {
128128 for ( const vAttrs of [ state . getVertexState ( e . head ) ?. attributes , state . getVertexState ( e . tail ) ?. attributes ] ) {
129129 vAttrs ?. set ( attribute . color , toHighlight . color ) ;
0 commit comments