/****************************************************************/ /* */ /* AdjacencyMatrixImport.cpp */ /* Reads in graph given by the Adjacency Matrix. */ /* Expected input is =, */ /* Where is a positive number, */ /* and is a x 0-1 matrix. */ /* The delimeters between the numbers can be any white */ /* space. Any remaining data in the file is ignored. */ /* If there is no enough tokens to generate the graph */ /* an exception is generated. */ /* */ /* Written by Vakhid Masagutov. */ /* September 25, 2001 */ /* */ /****************************************************************/ #include #include #include using namespace std; struct AdjacencyMatrixImport:public ImportModule { AdjacencyMatrixImport(ClusterContext context):ImportModule(context){ addParameter("filename"); } ~AdjacencyMatrixImport(){} bool import(const string &name) { std::ifstream in(name.c_str()); unsigned int size=0,size1=0; string v; char ch; in>>size>>ch>>size1; //some error checking if (size==0) { std::cerr<<"****\n**** File "<addNode(); StringProxy *labels=getLocalProxy(superGraph,"viewLabel"); //create edges for (unsigned int i=0;i>v;j++) { //the following is going to ignore multiple //edges. Do we need them? if (j==i) labels->setNodeValue(nodes[i],v.c_str()); else if (v!="0") superGraph->addEdge(nodes[i],nodes[j]); } if (j!=size) { std::cerr<<"****\n**** File "<>x) std::cerr<<"****\n**** File "<