001 /* 002 * $Id: Dimension.java 3058 2010-03-27 11:05:23Z kredel $ 003 */ 004 005 package edu.jas.application; 006 007 008 import java.io.Serializable; 009 import java.util.Arrays; 010 import java.util.Set; 011 012 013 /** 014 * Container for dimension parameters. 015 * @author Heinz Kredel 016 */ 017 public class Dimension implements Serializable { 018 019 020 /** 021 * Ideal dimension. 022 */ 023 public final int d; 024 025 026 /** 027 * Indices of a maximal independent set (of variables). 028 */ 029 public final Set<Integer> S; 030 031 032 /** 033 * Set of indices of all maximal independent sets (of variables). 034 */ 035 public final Set<Set<Integer>> M; 036 037 038 /** 039 * Names of all variables. 040 */ 041 public final String[] v; 042 043 044 /** 045 * Constructor. 046 * @param d ideal dimension. 047 * @param S indices of a maximal independent set (of variables) 048 * @param M set of indices of all maximal independent sets (of variables) 049 * @param v names of all variables 050 */ 051 public Dimension(int d, Set<Integer> S, Set<Set<Integer>> M, String[] v) { 052 this.d = d; 053 this.S = S; 054 this.M = M; 055 this.v = v; 056 } 057 058 059 /** 060 * String representation of the ideal. 061 * @see java.lang.Object#toString() 062 */ 063 @Override 064 public String toString() { 065 StringBuffer sb = new StringBuffer("Dimension( " + d + ", "); 066 if (v == null) { 067 sb.append("" + S + ", " + M + " )"); 068 return sb.toString(); 069 } 070 String[] s = new String[S.size()]; 071 int j = 0; 072 for (Integer i : S) { 073 s[j] = v[i]; 074 j++; 075 } 076 sb.append(Arrays.toString(s) + ", "); 077 sb.append("[ "); 078 boolean first = true; 079 for (Set<Integer> m : M) { 080 if (first) { 081 first = false; 082 } else { 083 sb.append(", "); 084 } 085 s = new String[m.size()]; 086 j = 0; 087 for (Integer i : m) { 088 s[j] = v[i]; 089 j++; 090 } 091 sb.append(Arrays.toString(s)); 092 } 093 sb.append(" ] )"); 094 return sb.toString(); 095 } 096 }