/* Research Project: Graphical Database for Category Theory J. Bradbury, Dr. R. Rosebrugh, I. Rutherford Mount Allison University 2001 File: Clan.java (authory: Larry Barowski, Auburn University, 12/4/96) Description: A "Clan" class for CGD. */ //import statements import java.lang.String; public class Clan { public final static int UNKNOWN = 0; public final static int INDEPENDENT = 1; public final static int LINEAR = 2; public final static int PRIMITIVE = 3; public final static int PSEUDOINDEPENDENT = 4; public final static int SINGLETON = 5; public int clanType; public int id; public Set nodes; public Set sources; public Set sinks; public int size; // number of nodes in the clan public int order; // ordering for clan // is just the topo. no. from any node public Clan next; // For use in stack of clans. public Clan listnext; // For use in list of clans. public Clan(int type, Set nodes_in, Set sources_in, Set sinks_in, int order_in) { clanType = type; nodes = nodes_in; size = nodes.numberOfElements(); sources = sources_in; sinks = sinks_in; order = order_in; next = listnext = null; } public String toString() { String string = new String(); string += new String(" ILPiS").charAt(clanType); string += ": "; string += nodes.toShortString(); return string; } // Translate indexes to ids for graph. public String toString(Graph graph) { String string = new String(); string += new String(" ILPiS").charAt(clanType); string += ": "; string += "("; int index; boolean first = true; int numnodes = graph.numberOfNodes(); for(index = nodes.first(); index != -1; index = nodes.next()) { if(!first) string += ", "; else first = false; if(index < numnodes) string = string + graph.getNodeFromIndex(index).getId(); else string += "d_" + index; if(nodes.isElement(index + 1) && nodes.isElement(index + 2)) { string += "-"; while(nodes.isElement(index + 1)) index = nodes.next(); if(index < numnodes) string += graph.getNodeFromIndex(index).getId(); else string += "dummy_" + index; } } string = string + ")"; return string; } }