该帮助的版本不再更新,请参见https://www.jmp.com/support/help/zh-cn/15.2 获取最新的版本.


g = Associative Array();
g[1] = Associative Array({1, 2, 4});
g[2] = Associative Array({1, 3});
g[3] = Associative Array({4, 5});
g[4] = Associative Array({4, 5});
g[5] = Associative Array({1, 2});
This is a two-level associative array. The associative array g contains five associative arrays (1, 2, 3, 4, and 5). In the containing array g, both the keys (1-5) and the values (the arrays that define the map) are important. In the inner associative arrays, the values do not matter. Only the keys are important.
图 7.2 Example of a Directed Graph
dfs = Function( {ref, node, visited},
Write( "\!NNode: ", node, ", ", ref[node] << Get Keys );
While( !Is Missing( chnode ),
If( !visited[chnode],
visited = Recurse( ref, chnode, visited )
chnode = tmp << Next( chnode );
注意: 
dfs( g, 2, J( N Items( g << Get Keys ), 1, 0 ) );
New Window( "Directed Graph",
Graph Box(
Frame Size( 300, 300 ),
X Scale( -1.5, 1.5 ),
Y Scale( -1.5, 1.5 ),
Local( {n = N Items( g ), k = 2 * Pi() / n, r, i, pt, from, to,
Fill Color( "green" );
Pen Size( 3 );
r = 1 / (n + 2);
For( i = 1, i <= n, i++,
pt = Eval List( {Cos( k * i ), Sin( k * i )} );
For( edge = edges << First, !Is Empty( edge ),
edge = edges << Next( edge ),
to = Eval List( {Cos( k * edge ), Sin( k * edge )} );
Circle( Eval List( 1.2 * pt ), 0.9 * r ), // else
d = Sqrt( Sum( v * v ) );
{from, to} = Eval List(
Arrow( from, to );
Circle( pt, r, "fill" );
Text( Center Justified, pt - {0, 0.05}, Char( i ) );