%%%%%%% % make_radial.m % Authors: Laurie Heyer & Lance Harden, Davidson College % June 30, 2006 % % Description: Make_radial creates a radial pancake graph for a stack of k % pancakes. Given a desired center node, root, and the diameter of the % graph, diam, make_radial separates the nodes of the adjacency matrix into % ranks based on their distance from the root. It computes x- and % y-coordinates for the nodes so that each rank of nodes are placed in % ascending order in concentric circles around the root. The nodes in each % rank are evenly spaced around their respective circle. Rings allows the % user to graph selected distance groups. [1 3] would create a graph of % only the nodes distance 1 and distance 3 from the root. function make_radial(k,root,diam,rings) d=[]; dispnodes = []; if rings(1) == 0 dispnodes(1) = root; end A = signedperms(k); b = length(A); adj = adjmat(k,1:b); runningor = zeros(length(adj)); countcord = 1; r = 0; x(1) = .5; y(1) = .5; nodes{1} = mat2str(A(root,:)); for iring = 1:diam path = adj^iring & ~runningor; newd = setdiff(find(path(root,:)),root); d = [d newd]; num(iring) = length(newd); r = r + .5/diam; if ismember(iring,rings) dispnodes = [dispnodes (countcord+1):(countcord+length(newd))]; end for icord = 1:length(newd) x(countcord + icord) = .5 + r*cos(((icord-1) * 2 * pi)/(length(newd))); y(countcord + icord) = .5 + r*sin(((icord-1) * 2 * pi)/(length(newd))); nodes{countcord + icord} = mat2str(A(newd(icord),:)); end countcord = countcord + length(newd); runningor = runningor | adj^iring; end d = [root d]; adj = adj(d,d); adj = adj(dispnodes,dispnodes); cd GraphViz2Mat1.2/ figure graph_draw(adj,'X',x(dispnodes),'Y',y(dispnodes),'linecolor','Green','node_labels',nodes(:,dispnodes),'fontsize',12); cd ..