Last active
June 18, 2019 21:59
-
-
Save kenwebb/6882561aa5b59ab93cace22d02840bae to your computer and use it in GitHub Desktop.
Bigraphs 2019 01 - A Bigraph Relational Model
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!--Xholon Workbook http://www.primordion.com/Xholon/gwt/ MIT License, Copyright (C) Ken Webb, Tue Jun 18 2019 17:58:46 GMT-0400 (Eastern Daylight Time)--> | |
<XholonWorkbook> | |
<Notes><![CDATA[ | |
Xholon | |
------ | |
Title: Bigraphs 2019 01 - A Bigraph Relational Model | |
Description: | |
Url: http://www.primordion.com/Xholon/gwt/ | |
InternalName: 6882561aa5b59ab93cace22d02840bae | |
Keywords: | |
My Notes | |
-------- | |
June 13, 2019 | |
In this workbook, I explore and implement the bigraph Vending Machine example [1]. See Figure 1 and the bigraph specification on page 16. | |
I will try to implement the example in Xholon, by taking the following specification[1] as code in a Bigraph Domain Specific Language (DSL). | |
A bigraph B under a signature Σ is defined as | |
B=(VB,EB,PB,ctrlB,prntB,linkB):〈m,X〉→〈n,Y〉 | |
Bigraph Specification (with added line numbers) | |
--------------------- | |
1 Σ=({get,send,sum},{(get,1),(send,1),(sum,0)}), | |
2 VB={a,b,d,e,f,g,h,i,j,k,l}, | |
3 EB=∅, | |
4 PB={p(b,1),p(e,1),p(g,1),p(i,1),p(j,1),p(l,1)}, | |
5 ctrlB={(a,sum),(b,send),(d,sum),(e,get),(f,sum),(g,get),(h,sum),(i,send),(j,get),(k,sum),(l,send)}, | |
6 prntB={(a,0),(f,0),(b,a),(d,b),(e,d),(g,f),(h,g),(i,h),(j,f),(k,j),(l,k)}, | |
7 linkB={(p(b,1),c),(p(e,1),co),(p(g,1),c),(p(i,1),co),(p(j,1),c),(p(l,1),t), | |
8 m=0,X=∅,n=1,and,Y={c,co,t} | |
----- | |
Bigraph Specification (details on each line) | |
--------------------- | |
1 Σ is a signature | |
2 VB a set of nodes (vertices); note that "k" was missing | |
3 EB a set of edges | |
4 PB a set of ports | |
5 ctrlB a set of controls | |
6 prntB a set of parent pairs | |
7 linkB maps links; note the missing "}" | |
8 note the unnecessary word "and" | |
----- | |
TODO | |
---- | |
- how do I handle inner and outer names? | |
- perhaps they could be Xholon nodes within an array called outerNames in me or me.parent() ? | |
- I think these are ROOM/OT/eTrice relay ports | |
- how do I specify edges in my enhanced bigraph specification? | |
- an edge is just a label, the name of a hyperedge (see ref[2]) | |
- and see ref[1] page 15-17, especially first para on page 16 | |
- an edge is just an identifier | |
- also see page 35-36 of ref[1] | |
- edges become links between ports and outer names | |
- maybe this has something to do with the fact that a Xholon edge/link can be specified as a path over the place graph (using XPath, etc.) | |
- and XML and HTML also use XPath | |
- there needs to a way with bigraphs to specify class inheritance | |
- probably using something analogous to prntB | |
graphviz | |
-------- | |
/* | |
Automatically generated by Xholon version 0.9.1, using org.primordion.ef.Xholon2Graphviz.java | |
Fri Jun 14 10:34:57 GMT-400 2019 1560522897863 | |
model: Bigraphs 2019 01 - A Bigraph Relational Model | |
www.primordion.com/Xholon | |
To view this file, use Graphviz dot|fdp|neato|twopi|circo|sfdp from http://www.graphviz.org/ | |
For example, to generate an SVG file: | |
dot -Tsvg -O BigraphSystem_45_1560522897863.gv | |
Alternatively try one of these: | |
dot -Tsvg -O BigraphSystem_45_1560522897863.gv | |
dot -Tsvg -O -Grankdir=LR BigraphSystem_45_1560522897863.gv | |
fdp -Tsvg -O BigraphSystem_45_1560522897863.gv | |
neato -Tsvg -O BigraphSystem_45_1560522897863.gv | |
circo -Tsvg -O BigraphSystem_45_1560522897863.gv | |
Or use one of: -Tgif -Tjpg -Tpdf -Tpng -Txdot -Txlib | |
See also: http://www.webgraphviz.com/ | |
See also: http://rise4fun.com/agl/ | |
To repeat this Xholon export: | |
$wnd.xh.xport("Graphviz", $wnd.xh.root().parent().xpath("Chameleon/BigraphSystem"), '{"gvFileExt":".gv","gvGraph":"digraph","layout":"dot","edgeOp":"->","gvCluster":"cluster","shouldShowStateMachineEntities":false,"filter":"--Behavior,Script","nameTemplateNodeId":"^^^^i^","nameTemplateNodeLabel":"r c^^^","shouldQuoteLabels":true,"shouldShowLinks":true,"shouldShowLinkLabels":false,"shouldSpecifyLayout":false,"maxLabelLen":-1,"shouldColor":true,"defaultNodeColor":"#ffffff","bgGraphColor":"white","shouldSpecifyShape":true,"shape":"box","shouldSpecifySize":true,"size":"22","shouldSpecifyFontname":true,"fontname":"\"Courier New\"","shouldSpecifyArrowhead":false,"arrowhead":"vee","shouldSpecifyStylesheet":true,"stylesheet":"Xholon.css","shouldSpecifyRankdir":true,"rankdir":"TB","shouldDisplayGraph":true,"outputFormat":"svg"}'); | |
*/ | |
digraph 45 { | |
graph [label="0 bigraphSystem",id="BigraphSystem",stylesheet="Xholon.css",rankdir=TB,size=22,fontname="Courier New",compound=true,bgcolor=white] | |
node [style=filled,fillcolor="#ffffff",shape=box,fontname="Courier New"] | |
subgraph cluster51 { label="a sum" id="BigraphSystem/sum[@roleName='a']" | |
subgraph cluster53 { label="b send" id="BigraphSystem/sum[@roleName='a']/send" | |
subgraph cluster55 { label="d sum" id="BigraphSystem/sum[@roleName='a']/send/sum" | |
57 [label="e get" id="BigraphSystem/sum[@roleName='a']/send/sum/get"] | |
} | |
} | |
} | |
subgraph cluster59 { label="f sum" id="BigraphSystem/sum[@roleName='f']" | |
subgraph cluster61 { label="g get" id="BigraphSystem/sum[@roleName='f']/get[@roleName='g']" | |
subgraph cluster63 { label="h sum" id="BigraphSystem/sum[@roleName='f']/get[@roleName='g']/sum" | |
65 [label="i send" id="BigraphSystem/sum[@roleName='f']/get[@roleName='g']/sum/send"] | |
} | |
} | |
subgraph cluster67 { label="j get" id="BigraphSystem/sum[@roleName='f']/get[@roleName='j']" | |
subgraph cluster69 { label="k sum" id="BigraphSystem/sum[@roleName='f']/get[@roleName='j']/sum" | |
71 [label="l send" id="BigraphSystem/sum[@roleName='f']/get[@roleName='j']/sum/send"] | |
} | |
} | |
} | |
} | |
export graphviz from Dev Tools | |
------------------------------ | |
xh.xport("Graphviz", xh.root().parent().xpath("Chameleon/BigraphSystem"), '{"gvFileExt":".gv","gvGraph":"digraph","layout":"dot","edgeOp":"->","gvCluster":"cluster","shouldShowStateMachineEntities":false,"filter":"--Behavior,Script","nameTemplateNodeId":"^^^^i^","nameTemplateNodeLabel":"r c^^^","shouldQuoteLabels":true,"shouldShowLinks":true,"shouldShowLinkLabels":false,"shouldSpecifyLayout":false,"maxLabelLen":-1,"shouldColor":true,"defaultNodeColor":"#ffffff","bgGraphColor":"white","shouldSpecifyShape":true,"shape":"box","shouldSpecifySize":true,"size":"22","shouldSpecifyFontname":true,"fontname":"Courier","shouldSpecifyArrowhead":false,"arrowhead":"vee","shouldSpecifyStylesheet":true,"stylesheet":"Xholon.css","shouldSpecifyRankdir":true,"rankdir":"TB","shouldDisplayGraph":true,"outputFormat":"svg"}'); | |
References | |
---------- | |
(1) https://arxiv.org/pdf/1111.0086.pdf | |
A Bigraph Relational Model, by Maxime Beauquier and Carstern Schurmann, IT University of Copenhagen, 2011 | |
(2) BigActors - A Model for Structure-aware Computation, by Eloi Pereira et al, 2013 (page 2) | |
A bigraph B is called concrete when each node and each edge is assigned a unique identifier (known as support). | |
We denote the set of node identifiers of B as VB and the set of edge identifiers as EB (e.g. VB = {m0,m1,m2,q0,q1} and EB = {e} in the example of Figure 2). | |
]]></Notes> | |
<params> | |
<param name="MaxPorts" value="5"/> | |
</params> | |
<_-.XholonClass> | |
<BigraphSystem/> | |
</_-.XholonClass> | |
<xholonClassDetails> | |
<Avatar><Color>red</Color></Avatar> | |
</xholonClassDetails> | |
<BigraphSystem> | |
<!-- this is the original specification from ref [1] --> | |
<Bigraph roleName="0"><Attribute_String><![CDATA[ | |
B=(VB,EB,PB,ctrlB,prntB,linkB):〈m,X〉→〈n,Y〉, | |
m=0,X=∅,n=1,Y={c,co,t}, | |
Σ=({get,send,sum},{(get,1),(send,1),(sum,0)}), | |
VB={a,b,d,e,f,g,h,i,j,k,l}, | |
EB=∅, | |
PB={p(b,1),p(e,1),p(g,1),p(i,1),p(j,1),p(l,1)}, | |
ctrlB={(a,sum),(b,send),(d,sum),(e,get),(f,sum),(g,get),(h,sum),(i,send),(j,get),(k,sum),(l,send)}, | |
prntB={(a,0),(f,0),(b,a),(d,b),(e,d),(g,f),(h,g),(i,h),(j,f),(k,j),(l,k)}, | |
linkB={(p(b,1),c),(p(e,1),co),(p(g,1),c),(p(i,1),co),(p(j,1),c),(p(l,1),t)} | |
]]></Attribute_String></Bigraph> | |
<!-- I've added a second linkB, a second PB, and a second EB; and I removed the signature Σ because this has already been defined above --> | |
<Bigraph roleName="1"><Attribute_String><![CDATA[ | |
B=(VB,EB,PB,ctrlB,prntB,linkB):〈m,X〉→〈n,Y〉, | |
m=0,X=∅,n=1,Y={c,co,t}, | |
VB={a,b,d,e,f,g,h,i,j,k,l}, | |
EB=∅, | |
EB={q}, | |
PB={p(b,1),p(e,1),p(g,1),p(i,1),p(j,1),p(l,1)}, | |
PB={p(e,1),p(e,2)}, | |
ctrlB={(a,sum),(b,send),(d,sum),(e,get),(f,sum),(g,get),(h,sum),(i,send),(j,get),(k,sum),(l,send)}, | |
prntB={(a,0),(f,0),(b,a),(d,b),(e,d),(g,f),(h,g),(i,h),(j,f),(k,j),(l,k)}, | |
linkB={(p(b,1),c),(p(e,1),co),(p(g,1),c),(p(i,1),co),(p(j,1),c),(p(l,1),t)}, | |
linkB={(p(e,1),l),(p(e,2),i)} | |
]]></Attribute_String></Bigraph> | |
<!-- parse a bigraph(B) interface and signature(Σ) --> | |
<Bigraph roleName="2"><Attribute_String><![CDATA[ | |
B=(VB,EB,PB,ctrlB,prntB,linkB):〈m,X〉→〈n,Y〉, | |
m=0,X=∅,n=1,Y={aaa,bbb,ccc}, | |
Σ=({one,two,three},{(one,1),(two,1),(three,0)}) | |
]]></Attribute_String></Bigraph> | |
<Bigraph roleName="2a"><Attribute_String><![CDATA[ | |
VB={a1,a2,a3,b1,c1,c2}, | |
EB={q,r}, | |
PB={p(a1,1),p(c2,1)}, | |
ctrlB={(a1,one),(a2,two),(a3,three),(b1,one),(c1,one),(c2,two)}, | |
prntB={(a1,0),(a2,a1),(a3,a2),(b1,a1),(c1,a1),(c2,a1)}, | |
linkB={(p(a1,1),c2),(p(c1,1),b1)} | |
]]></Attribute_String></Bigraph> | |
<Bigraph roleName="2b"><Attribute_String><![CDATA[ | |
VB={d1,d2,d3,e1,f1,f2}, | |
EB={s,t}, | |
PB={p(d1,1),p(f2,1)}, | |
ctrlB={(d1,one),(d2,two),(d3,three),(e1,one),(f1,one),(f2,two)}, | |
prntB={(d1,0),(d2,d1),(d3,d2),(e1,d1),(f1,d1),(f2,d1)}, | |
linkB={(p(d1,1),f2),(p(f1,1),e1)} | |
]]></Attribute_String></Bigraph> | |
<!-- Operand as a Bigraph "Pixel Array 1.1" | |
pack P' = {} | |
pack P1 = {w1, x1} | |
pack P2 = {w2, y2} | |
cables C = {w, x, y} | |
bindings w1,w2 |-> w | |
bindings x1 |-> x | |
bindings y2 |-> y | |
morphism (P1, P2) -> P' | |
- there are many differences between bigraphs and operads, and yet they both handle place graphs and link graphs | |
--> | |
<Bigraph roleName="3"><Attribute_String><![CDATA[ | |
B=(VB,EB,PB,ctrlB,prntB,linkB):〈m,X〉→〈n,Y〉, | |
m=0,X=∅,n=1,Y={c,co,t}, | |
Σ=({P0,P1,P2,C},{(P0,0),(P1,2),(P2,2),(C,0)}), | |
VB={p0,p1,p2,c}, | |
EB=∅, | |
PB={p(p1,1),p(p1,2),p(p2,1),p(p2,2),p(c,1),p(c,2),p(c,3)}, | |
ctrlB={(p0,P0),(p1,P1),(p2,P2),(c,C)}, | |
prntB={(p0,0),(p1,p0),(p2,p0)}, | |
linkB={(p(p1,1),c),(p(p1,2)c),(p(p2,1)c),(p(p2,2),c)} | |
]]></Attribute_String></Bigraph> | |
</BigraphSystem> | |
<Bigraphbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[ | |
const DEFAULT_SITES_SYMBOL = "m"; | |
const DEFAULT_INNERNAMES_SYMBOL = "X"; | |
const DEFAULT_ROOTS_SYMBOL = "n"; | |
const DEFAULT_OUTERNAMES_SYMBOL = "Y"; | |
var me, spec, nodeDict, edgeDict, portDict, sitesSymbol, innerNamesSymbol, rootsSymbol, outerNamesSymbol, interface, beh = { | |
postConfigure: function() { | |
me = this.cnode.parent(); | |
//me.println(me.name()); | |
spec = me.first().text().trim(); | |
nodeDict = {}; | |
edgeDict = {}; | |
portDict = {}; | |
// default values of symbols | |
sitesSymbol = DEFAULT_SITES_SYMBOL; | |
innerNamesSymbol = DEFAULT_INNERNAMES_SYMBOL; | |
rootsSymbol = DEFAULT_ROOTS_SYMBOL; | |
outerNamesSymbol = DEFAULT_OUTERNAMES_SYMBOL; | |
interface = {}; | |
me.first().remove(); | |
this.parseSpec(spec); | |
this.cnode.remove(); | |
if (!me.first()) { | |
//me.remove(); | |
} | |
}, | |
parseSpec: function(spec) { | |
const arr = spec.split("\n"); | |
for (var i = 0; i < arr.length; i++) { | |
const line = arr[i]; | |
const larr = line.split("="); | |
const larr0 = larr[0].trim(); | |
const larr1 = larr[1].substring(0, larr[1].length - (larr[1].endsWith(",") ? 1 : 0)).trim(); // remove trailing "," if it exists | |
//me.println("" + (i+1) + " " + larr0 + " = " + larr1); | |
switch (larr0) { | |
case "B": | |
this.parseBigraph(larr1); | |
break; | |
case "Σ": | |
this.parseSignature(larr1); | |
break; | |
case "VB": | |
this.parseVB(larr1); | |
break; | |
case "EB": | |
this.parseEB(larr1); | |
break; | |
case "PB": | |
this.parsePB(larr1); | |
break; | |
case "ctrlB": | |
this.parseCtrlB(larr1); | |
break; | |
case "prntB": | |
this.parsePrntB(larr1); | |
break; | |
case "linkB": | |
this.parseLinkB(larr1); | |
break; | |
default: | |
// m=0,X=∅,n=1,Y={c,co,t} | |
const line2 = line.substring(0, line.length-1); // remove trailing "," | |
const fixedLine = this.preParseInterface(line2); | |
this.parseInterface(fixedLine); | |
break; | |
} | |
} | |
}, | |
// (VB,EB,PB,ctrlB,prntB,linkB):〈m,X〉→〈n,Y〉 | |
parseBigraph: function(str) { | |
const strArr = str.split(":"); | |
const strArr2 = strArr[1].substring(1,strArr[1].length-1).split("〉→〈"); | |
const innerInterface = strArr2[0].split(","); | |
const outerInterface = strArr2[1].split(","); | |
//me.println(innerInterface + " " + outerInterface); | |
sitesSymbol = innerInterface[0]; // "m" | |
innerNamesSymbol = innerInterface[1]; // "X" | |
rootsSymbol = outerInterface[0]; // "n" | |
outerNamesSymbol = outerInterface[1]; // "Y" | |
//me.println(sitesSymbol + " " + innerNamesSymbol + " " + rootsSymbol + " " + outerNamesSymbol); | |
}, | |
/** | |
* @param str example: m=0,X=∅,n=1,Y={c,co,t} | |
* @return example: m=0|X=∅|n=1|Y={c,co,t} | |
*/ | |
preParseInterface: function(str) { | |
// generate 5 segments example: m 0,X ∅,n 1,Y {c,co,t} | |
const segmentArr = str.split("="); | |
const seg1 = segmentArr[1].trim(); | |
const seg2 = segmentArr[2].trim(); | |
const seg3 = segmentArr[3].trim(); | |
const seg1len = seg1.length; | |
const seg2len = seg2.length; | |
const seg3len = seg3.length; | |
// fix segments 1 2 3 | |
const segment0 = segmentArr[0].trim(); | |
const segment1 = seg1.substring(0,seg1len-2) + "|" + seg1.substring(seg1len-1); | |
const segment2 = seg2.substring(0,seg2len-2) + "|" + seg2.substring(seg2len-1); | |
const segment3 = seg3.substring(0,seg3len-2) + "|" + seg3.substring(seg3len-1); | |
const segment4 = segmentArr[4].trim(); | |
return segment0 + "=" + segment1 + "=" + segment2 + "=" + segment3 + "=" + segment4; | |
}, | |
// m=0,X=∅,n=1,Y={c,co,t} | |
parseInterface: function(str) { | |
const strArr = str.split("|"); | |
for (var i = 0; i < strArr.length; i++) { | |
let itemArr = strArr[i].split("="); | |
switch (itemArr[0]) { | |
case sitesSymbol: interface[sitesSymbol] = itemArr[1]; break; | |
case innerNamesSymbol: | |
// this might be ∅ or the first part of {a,b,c} | |
interface[innerNamesSymbol] = itemArr[1]; | |
break; | |
case rootsSymbol: interface[rootsSymbol] = itemArr[1]; break; | |
case outerNamesSymbol: | |
// this might be ∅ or the first part of {a,b,c} | |
interface[outerNamesSymbol] = itemArr[1]; | |
break; | |
default: me.println("unknown " + strArr[i]); break; | |
} | |
} | |
//me.println(JSON.stringify(interface)); | |
}, | |
// ({get,send,sum},{(get,1),(send,1),(sum,0)}) | |
parseSignature: function(str) { | |
const str2 = str.substring(2,str.length-2); | |
const strArr = str2.split("},{"); | |
const ctrlSet = strArr[0].trim(); | |
const portAritySet = strArr[1].trim(); | |
const ctrlSetArr = ctrlSet.split(","); | |
const portAritySetArr = portAritySet.substring(1,portAritySet.length-1 ).split("),("); | |
// add nodes to Inheritance Hierarchy | |
const xhcRoot = $wnd.xh.root().xhc().parent(); | |
let xhcStr = "<_-.ih>"; | |
for (var i = 0; i < ctrlSetArr.length; i++) { | |
xhcStr += "<" + ctrlSetArr[i] + "/>"; | |
} | |
xhcStr += "</_-.ih>"; | |
xhcRoot.append(xhcStr); | |
// add ports to Inheritance Hierarchy class details | |
let xhcCdStr = "<xholonClassDetails>"; | |
for (var j = 0; j < portAritySetArr.length; j++) { | |
let portArityPair = portAritySetArr[j].split(","); | |
// ignore if arity is 0 | |
let xhcName = portArityPair[0]; | |
let portCount = portArityPair[1]; | |
if (portCount > 0) { | |
xhcCdStr += "<" + xhcName + ' xhType="XhtypePureActiveObject">'; | |
for (var k = 0; k < portCount; k++) { | |
xhcCdStr += '<port name="port" index="' + k + '" connector="null"></port>'; | |
} | |
xhcCdStr += "</" + xhcName + ">"; | |
} | |
} | |
xhcCdStr += "</xholonClassDetails>"; | |
xhcRoot.append(xhcCdStr); | |
}, | |
// {a,b,d,e,f,g,h,i,j,k,l} | |
parseVB: function(str) { | |
if (str == "∅") { | |
return; // the set of vertices = the empty set | |
} | |
const str2 = str.substring(1,str.length-1); | |
const strArr = str2.split(","); | |
for (var i = 0; i < strArr.length; i++) { | |
let node = strArr[i]; // ex: "a" | |
nodeDict[node] = null; | |
} | |
}, | |
// {q,r,s} | |
parseEB: function(str) { | |
if (str == "∅") { | |
return; // the set of edges = the empty set | |
} | |
const str2 = str.substring(1,str.length-1); | |
const strArr = str2.split(","); | |
for (var i = 0; i < strArr.length; i++) { | |
let edge = strArr[i]; // ex: "q" | |
edgeDict[edge] = null; | |
} | |
}, | |
// {p(b,1),p(e,1),p(g,1),p(i,1),p(j,1),p(l,1)} | |
parsePB: function(str) { | |
if (str == "∅") { | |
return; // the set of ports = the empty set | |
} | |
const str2 = str.substring(3,str.length-2); | |
const strArr = str2.split("),p("); | |
for (var i = 0; i < strArr.length; i++) { | |
let port = strArr[i]; // ex: "b,1" | |
portDict[port] = null; | |
} | |
}, | |
// {(a,sum),(b,send),(d,sum),(e,get),(f,sum),(g,get),(h,sum),(i,send),(j,get),(k,sum),(l,send)} | |
parseCtrlB: function(str) { | |
const str2 = str.substring(2,str.length-2); | |
const strArr = str2.split("),("); | |
const root = me; //me.parent(); | |
for (var i = 0; i < strArr.length; i++) { | |
let pairArr = strArr[i].split(","); | |
let node = pairArr[0]; // ex: "a" | |
if (nodeDict[node] == null) { | |
let ctrl = pairArr[1]; // ex: "sum" | |
let xhStr = '<' + ctrl + ' roleName="' + node + '"/>'; | |
root.append(xhStr); | |
nodeDict[node] = root.last(); | |
} | |
else { | |
// it might be undefined (it waas not an element in VB), or it might have a non-null value (it may be a duplicate on ctrlB) | |
me.println("WARNING: control " + node + " is " + nodeDict[node]); | |
} | |
} | |
}, | |
// {(a,0),(f,0),(b,a),(d,b),(e,d),(g,f),(h,g),(i,h),(j,f),(k,j),(l,k)} | |
parsePrntB: function(str) { | |
const str2 = str.substring(2,str.length-2); | |
const strArr = str2.split("),("); | |
const root = me; //me.parent(); | |
for (var i = 0; i < strArr.length; i++) { | |
let pairArr = strArr[i].split(","); | |
let nodeStr = pairArr[0]; // ex: "b" | |
let prntStr = pairArr[1]; // ex: "a" | |
let node = nodeDict[nodeStr]; | |
let prnt = root; | |
if (prntStr != "0") { | |
prnt = nodeDict[prntStr]; | |
} | |
if (node == null) {me.println("WARNING: " + nodeStr + " is null");} | |
else if (prnt == null) {me.println("WARNING: " + nodeStr + " is null");} | |
else { | |
prnt.append(node.remove()) | |
} | |
} | |
}, | |
// {(p(b,1),c),(p(e,1),co),(p(g,1),c),(p(i,1),co),(p(j,1),c),(p(l,1),t)} | |
parseLinkB: function(str) { | |
const str2 = str.substring(2,str.length-2); | |
const strArr = str2.split("),("); | |
for (var i = 0; i < strArr.length; i++) { | |
let pairArr = strArr[i].split(","); | |
let portStr = pairArr[0] + "," + pairArr[1]; // ex: "p(b,1)" | |
let portRefStr = pairArr[2]; // ex: "c" | |
//me.println(portStr + " -> " + portRefStr); | |
const sourceArr = portStr.substring(2, portStr.length-1).split(","); // ex: "b,1" | |
const sourceStr = sourceArr[0]; // ex: "b" | |
const sourcePortNum = sourceArr[1] - 1; // ex: "1" | |
//me.println(sourceStr + "." + sourcePortNum + " -> " + portRefStr); | |
// check if this port is defined in portDict | |
if (portDict[sourceStr + "," + sourcePortNum] == null) { | |
const srcNode = nodeDict[sourceStr]; | |
const trgNode = nodeDict[portRefStr]; | |
if (srcNode == null) {me.println("WARNING: " + sourceStr + " is null");} | |
else if (trgNode == null) {me.println("WARNING: " + portRefStr + " is null");} | |
else { | |
//me.println(srcNode.name() + "(" + sourcePortNum + ") -> " + trgNode.name()); | |
srcNode.port(sourcePortNum, trgNode); | |
portDict[sourceStr + "," + sourcePortNum] == trgNode; | |
} | |
} | |
else { | |
me.println("WARNING: port " + sourceStr + "," + sourcePortNum + " is " + portDict[sourceStr + "," + sourcePortNum]); | |
} | |
} | |
} | |
} | |
//# sourceURL=Bigraphbehavior.js | |
]]></Bigraphbehavior> | |
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml, | |
<svg width="100" height="50" xmlns="http://www.w3.org/2000/svg"> | |
<g> | |
<title>BigraphSystem</title> | |
<rect id="BigraphSystem" fill="#98FB98" height="50" width="50" x="25" y="0"/> | |
<g> | |
<title>BigraphSystem sum</title> | |
<rect id="BigraphSystem/*" fill="#6AB06A" height="50" width="10" x="80" y="0"/> | |
</g> | |
</g> | |
</svg> | |
<svg width="618pt" height="417pt" | |
viewBox="0.00 0.00 618.00 416.80" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> | |
<g id="BigraphSystem" class="graph" transform="scale(1 1) rotate(0) translate(4 412.8)"> | |
<title>45</title> | |
<polygon fill="white" stroke="none" points="-4,4 -4,-412.8 614,-412.8 614,4 -4,4"/> | |
<text text-anchor="middle" x="305" y="-8.2" font-family="Courier,monospace" font-size="14.00">bigraphSystem</text> | |
<g id="BigraphSystem/Bigraph[@roleName='0']" class="cluster"><title>cluster46</title> | |
<polygon fill="white" stroke="black" points="8,-204.8 8,-400.8 358,-400.8 358,-204.8 8,-204.8"/> | |
<text text-anchor="middle" x="183" y="-384.2" font-family="Courier,monospace" font-size="14.00">0 bigraph</text> | |
</g> | |
<g id="BigraphSystem/Bigraph[@roleName='0']/sum[@roleName='a']" class="cluster"><title>cluster53</title> | |
<polygon fill="white" stroke="black" points="244,-212.8 244,-368.8 350,-368.8 350,-212.8 244,-212.8"/> | |
<text text-anchor="middle" x="297" y="-352.2" font-family="Courier,monospace" font-size="14.00">a sum</text> | |
</g> | |
<g id="BigraphSystem/Bigraph[@roleName='0']/sum[@roleName='a']/send" class="cluster"><title>cluster55</title> | |
<polygon fill="white" stroke="black" points="252,-220.8 252,-336.8 342,-336.8 342,-220.8 252,-220.8"/> | |
<text text-anchor="middle" x="297" y="-320.2" font-family="Courier,monospace" font-size="14.00">b send</text> | |
</g> | |
<g id="BigraphSystem/Bigraph[@roleName='0']/sum[@roleName='a']/send/sum" class="cluster"><title>cluster57</title> | |
<polygon fill="white" stroke="black" points="260,-228.8 260,-304.8 334,-304.8 334,-228.8 260,-228.8"/> | |
<text text-anchor="middle" x="297" y="-288.2" font-family="Courier,monospace" font-size="14.00">d sum</text> | |
</g> | |
<g id="BigraphSystem/Bigraph[@roleName='0']/sum[@roleName='f']" class="cluster"><title>cluster61</title> | |
<polygon fill="white" stroke="black" points="16,-212.8 16,-368.8 236,-368.8 236,-212.8 16,-212.8"/> | |
<text text-anchor="middle" x="126" y="-352.2" font-family="Courier,monospace" font-size="14.00">f sum</text> | |
</g> | |
<g id="BigraphSystem/Bigraph[@roleName='0']/sum[@roleName='f']/get[@roleName='g']" class="cluster"><title>cluster63</title> | |
<polygon fill="white" stroke="black" points="130,-220.8 130,-336.8 228,-336.8 228,-220.8 130,-220.8"/> | |
<text text-anchor="middle" x="179" y="-320.2" font-family="Courier,monospace" font-size="14.00">g get</text> | |
</g> | |
<g id="BigraphSystem/Bigraph[@roleName='0']/sum[@roleName='f']/get[@roleName='g']/sum" class="cluster"><title>cluster65</title> | |
<polygon fill="white" stroke="black" points="138,-228.8 138,-304.8 220,-304.8 220,-228.8 138,-228.8"/> | |
<text text-anchor="middle" x="179" y="-288.2" font-family="Courier,monospace" font-size="14.00">h sum</text> | |
</g> | |
<g id="BigraphSystem/Bigraph[@roleName='0']/sum[@roleName='f']/get[@roleName='j']" class="cluster"><title>cluster69</title> | |
<polygon fill="white" stroke="black" points="24,-220.8 24,-336.8 122,-336.8 122,-220.8 24,-220.8"/> | |
<text text-anchor="middle" x="73" y="-320.2" font-family="Courier,monospace" font-size="14.00">j get</text> | |
</g> | |
<g id="BigraphSystem/Bigraph[@roleName='0']/sum[@roleName='f']/get[@roleName='j']/sum" class="cluster"><title>cluster71</title> | |
<polygon fill="white" stroke="black" points="32,-228.8 32,-304.8 114,-304.8 114,-228.8 32,-228.8"/> | |
<text text-anchor="middle" x="73" y="-288.2" font-family="Courier,monospace" font-size="14.00">k sum</text> | |
</g> | |
<g id="BigraphSystem/Bigraph[@roleName='1']" class="cluster"><title>cluster47</title> | |
<polygon fill="white" stroke="black" points="366,-32.8 366,-400.8 602,-400.8 602,-32.8 366,-32.8"/> | |
<text text-anchor="middle" x="484" y="-384.2" font-family="Courier,monospace" font-size="14.00">1 bigraph</text> | |
</g> | |
<g id="BigraphSystem/Bigraph[@roleName='1']/sum[@roleName='a']" class="cluster"><title>cluster76</title> | |
<polygon fill="white" stroke="black" points="431,-212.8 431,-368.8 537,-368.8 537,-212.8 431,-212.8"/> | |
<text text-anchor="middle" x="484" y="-352.2" font-family="Courier,monospace" font-size="14.00">a sum</text> | |
</g> | |
<g id="BigraphSystem/Bigraph[@roleName='1']/sum[@roleName='a']/send" class="cluster"><title>cluster78</title> | |
<polygon fill="white" stroke="black" points="439,-220.8 439,-336.8 529,-336.8 529,-220.8 439,-220.8"/> | |
<text text-anchor="middle" x="484" y="-320.2" font-family="Courier,monospace" font-size="14.00">b send</text> | |
</g> | |
<g id="BigraphSystem/Bigraph[@roleName='1']/sum[@roleName='a']/send/sum" class="cluster"><title>cluster80</title> | |
<polygon fill="white" stroke="black" points="447,-228.8 447,-304.8 521,-304.8 521,-228.8 447,-228.8"/> | |
<text text-anchor="middle" x="484" y="-288.2" font-family="Courier,monospace" font-size="14.00">d sum</text> | |
</g> | |
<g id="BigraphSystem/Bigraph[@roleName='1']/sum[@roleName='f']" class="cluster"><title>cluster84</title> | |
<polygon fill="white" stroke="black" points="374,-40.8 374,-196.8 594,-196.8 594,-40.8 374,-40.8"/> | |
<text text-anchor="middle" x="484" y="-180.2" font-family="Courier,monospace" font-size="14.00">f sum</text> | |
</g> | |
<g id="BigraphSystem/Bigraph[@roleName='1']/sum[@roleName='f']/get[@roleName='g']" class="cluster"><title>cluster86</title> | |
<polygon fill="white" stroke="black" points="488,-48.8 488,-164.8 586,-164.8 586,-48.8 488,-48.8"/> | |
<text text-anchor="middle" x="537" y="-148.2" font-family="Courier,monospace" font-size="14.00">g get</text> | |
</g> | |
<g id="BigraphSystem/Bigraph[@roleName='1']/sum[@roleName='f']/get[@roleName='g']/sum" class="cluster"><title>cluster88</title> | |
<polygon fill="white" stroke="black" points="496,-56.8 496,-132.8 578,-132.8 578,-56.8 496,-56.8"/> | |
<text text-anchor="middle" x="537" y="-116.2" font-family="Courier,monospace" font-size="14.00">h sum</text> | |
</g> | |
<g id="BigraphSystem/Bigraph[@roleName='1']/sum[@roleName='f']/get[@roleName='j']" class="cluster"><title>cluster92</title> | |
<polygon fill="white" stroke="black" points="382,-48.8 382,-164.8 480,-164.8 480,-48.8 382,-48.8"/> | |
<text text-anchor="middle" x="431" y="-148.2" font-family="Courier,monospace" font-size="14.00">j get</text> | |
</g> | |
<g id="BigraphSystem/Bigraph[@roleName='1']/sum[@roleName='f']/get[@roleName='j']/sum" class="cluster"><title>cluster94</title> | |
<polygon fill="white" stroke="black" points="390,-56.8 390,-132.8 472,-132.8 472,-56.8 390,-56.8"/> | |
<text text-anchor="middle" x="431" y="-116.2" font-family="Courier,monospace" font-size="14.00">k sum</text> | |
</g> | |
<!-- 59 --> | |
<g id="BigraphSystem/Bigraph[@roleName='0']/sum[@roleName='a']/send/sum/get" class="node"><title>59</title> | |
<polygon fill="#ffffff" stroke="black" points="325.495,-272.8 268.505,-272.8 268.505,-236.8 325.495,-236.8 325.495,-272.8"/> | |
<text text-anchor="middle" x="297" y="-250.6" font-family="Courier,monospace" font-size="14.00">e get</text> | |
</g> | |
<!-- 67 --> | |
<g id="BigraphSystem/Bigraph[@roleName='0']/sum[@roleName='f']/get[@roleName='g']/sum/send" class="node"><title>67</title> | |
<polygon fill="#ffffff" stroke="black" points="212.294,-272.8 145.706,-272.8 145.706,-236.8 212.294,-236.8 212.294,-272.8"/> | |
<text text-anchor="middle" x="179" y="-250.6" font-family="Courier,monospace" font-size="14.00">i send</text> | |
</g> | |
<!-- 73 --> | |
<g id="BigraphSystem/Bigraph[@roleName='0']/sum[@roleName='f']/get[@roleName='j']/sum/send" class="node"><title>73</title> | |
<polygon fill="#ffffff" stroke="black" points="106.294,-272.8 39.7057,-272.8 39.7057,-236.8 106.294,-236.8 106.294,-272.8"/> | |
<text text-anchor="middle" x="73" y="-250.6" font-family="Courier,monospace" font-size="14.00">l send</text> | |
</g> | |
<!-- 82 --> | |
<g id="BigraphSystem/Bigraph[@roleName='1']/sum[@roleName='a']/send/sum/get" class="node"><title>82</title> | |
<polygon fill="#ffffff" stroke="black" points="512.495,-272.8 455.505,-272.8 455.505,-236.8 512.495,-236.8 512.495,-272.8"/> | |
<text text-anchor="middle" x="484" y="-250.6" font-family="Courier,monospace" font-size="14.00">e get</text> | |
</g> | |
<!-- 90 --> | |
<g id="BigraphSystem/Bigraph[@roleName='1']/sum[@roleName='f']/get[@roleName='g']/sum/send" class="node"><title>90</title> | |
<polygon fill="#ffffff" stroke="black" points="570.294,-100.8 503.706,-100.8 503.706,-64.8 570.294,-64.8 570.294,-100.8"/> | |
<text text-anchor="middle" x="537" y="-78.6" font-family="Courier,monospace" font-size="14.00">i send</text> | |
</g> | |
<!-- 82->90 --> | |
<g id="BigraphSystem_edge2" class="edge"><title>82->90</title> | |
<path fill="none" stroke="black" d="M489.374,-236.564C498.643,-206.831 517.699,-145.709 528.689,-110.457"/> | |
<polygon fill="black" stroke="black" points="532.056,-111.417 531.691,-100.829 525.373,-109.334 532.056,-111.417"/> | |
</g> | |
<!-- 96 --> | |
<g id="BigraphSystem/Bigraph[@roleName='1']/sum[@roleName='f']/get[@roleName='j']/sum/send" class="node"><title>96</title> | |
<polygon fill="#ffffff" stroke="black" points="464.294,-100.8 397.706,-100.8 397.706,-64.8 464.294,-64.8 464.294,-100.8"/> | |
<text text-anchor="middle" x="431" y="-78.6" font-family="Courier,monospace" font-size="14.00">l send</text> | |
</g> | |
<!-- 82->96 --> | |
<g id="BigraphSystem_edge1" class="edge"><title>82->96</title> | |
<path fill="none" stroke="black" d="M478.626,-236.564C469.357,-206.831 450.301,-145.709 439.311,-110.457"/> | |
<polygon fill="black" stroke="black" points="442.627,-109.334 436.309,-100.829 435.944,-111.417 442.627,-109.334"/> | |
</g> | |
</g> | |
</svg> | |
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient> | |
</XholonWorkbook> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment