Author: ghuck Date: 2009-06-11 16:32:46 -0700 (Thu, 11 Jun 2009) New Revision: 16934
Modified: csplugins/trunk/soc/ghuck/gpuGraphDrawing/readFile.cu csplugins/trunk/soc/ghuck/gpuGraphDrawing/simpleCUDPP.cu csplugins/trunk/soc/ghuck/gpuGraphDrawing/writeOutput.cu Log: Minor changes. Modified: csplugins/trunk/soc/ghuck/gpuGraphDrawing/readFile.cu =================================================================== --- csplugins/trunk/soc/ghuck/gpuGraphDrawing/readFile.cu 2009-06-11 22:55:06 UTC (rev 16933) +++ csplugins/trunk/soc/ghuck/gpuGraphDrawing/readFile.cu 2009-06-11 23:32:46 UTC (rev 16934) @@ -16,99 +16,102 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. -See licence.h for more information. +See license.h for more information. **************************************************************************************/ #include "license.h" void error(const char * p, const char * p2="") { - printf("%s %s\n",p,p2); - exit(1); + printf("%s %s\n",p,p2); + exit(1); } + -void readGml(graph * g, FILE * from){ - - printf("Reading nodes!!\n"); - int numNodes; - char string[MAX_REC_LEN]; - fgets(string, MAX_REC_LEN,from ); // graph [ - fgets(string, MAX_REC_LEN,from ); // Creator "makegml" directed 0 label "" - fgets(string, MAX_REC_LEN,from ); - int i=0; - while(string[i]!='[') - i++; - int startPos = i; - numNodes = atoi(string+startPos+4); - while(fgets(string, MAX_REC_LEN,from )){ - int n = atoi(string+startPos+4); - if(n!=numNodes+1) - break; - else - numNodes = n; - //printf("!Node:%ld!\n",ftell (from)); - } - long int secFrom = ftell (from); - secFrom -= (long int)(strlen(string)+1); - - g->NodePos = (float2 *) malloc((numNodes)*sizeof(float2)); - g->AdjMatIndex = (int * ) calloc((numNodes+1),sizeof(int)); - g->AdjMatIndex[0]=0; - int numEdges = 0; - printf("Reading edges!!\n"); - i = 0; - while(string[i]!='[') - i++; - startPos = i; - int e1 = atoi(string+startPos+9 ); - i=startPos+9; - while(string[i]!= 't') - i++; - int e2 = atoi(string+i+ 6); - g->AdjMatIndex[e1]++; - g->AdjMatIndex[e2]++; - numEdges++; - - while(fgets(string, MAX_REC_LEN,from )){ - if((string[0]==']') || (string[1]==']')) - break; - numEdges++; - e1 = atoi(string+startPos+9 ); - i=0; - while(string[i]!= 't') - i++; - int e2 = atoi(string+i+ 6); - g->AdjMatIndex[e1]++; - g->AdjMatIndex[e2]++; - } - for(int i = 0; i < numNodes; i++) - g->AdjMatIndex[i+1] += g->AdjMatIndex[i]; - - printf("No of Edges: %d\n",numEdges); - g->AdjMatVals = (int * ) malloc(2*numEdges*sizeof(int)); - g->edgeLen = (int * ) malloc(2*numEdges*sizeof(int)); - int * temp = (int * ) calloc((numNodes),sizeof(int)); - initGraph(g,numNodes); g->numEdges = 2*numEdges; - - fseek ( from, secFrom, SEEK_SET ); - while(fgets(string, MAX_REC_LEN,from )){ - - if((string[0]==']') || (string[1]==']')) - break; - e1 = atoi(string+startPos+9 ); - i=0; - while(string[i]!= 't') - i++; - int e2 = atoi(string+i+ 6); - g->AdjMatVals[g->AdjMatIndex[e1-1]+temp[e1-1]] = e2-1; - g->AdjMatVals[g->AdjMatIndex[e2-1]+temp[e2-1]] = e1-1; - g->edgeLen[g->AdjMatIndex[e1-1]+temp[e1-1]] = EDGE_LEN; - g->edgeLen[g->AdjMatIndex[e2-1]+temp[e2-1]] = EDGE_LEN; - temp[e1-1]++; - temp[e2-1]++; - } - free(temp); - +// This function reads a graph from a file (from) stored in GML format +// TODO: FIX IT! It's giving segmentation fault!! + +void readGml(graph * g, FILE * from) +{ + printf("Reading nodes!!\n"); + int numNodes; + char string[MAX_REC_LEN]; + fgets(string, MAX_REC_LEN,from ); // graph [ + fgets(string, MAX_REC_LEN,from ); // Creator "makegml" directed 0 label "" + fgets(string, MAX_REC_LEN,from ); + int i=0; + while(string[i]!='[') + i++; + int startPos = i; + numNodes = atoi(string+startPos+4); + while(fgets(string, MAX_REC_LEN,from )){ + int n = atoi(string+startPos+4); + if(n!=numNodes+1) + break; + else + numNodes = n; + //printf("!Node:%ld!\n",ftell (from)); + } + long int secFrom = ftell (from); + secFrom -= (long int)(strlen(string)+1); + + g->NodePos = (float2 *) malloc((numNodes)*sizeof(float2)); + g->AdjMatIndex = (int * ) calloc((numNodes+1),sizeof(int)); + g->AdjMatIndex[0]=0; + int numEdges = 0; + printf("Reading edges!!\n"); + i = 0; + while(string[i]!='[') + i++; + startPos = i; + int e1 = atoi(string+startPos+9 ); + i=startPos+9; + while(string[i]!= 't') + i++; + int e2 = atoi(string+i+ 6); + g->AdjMatIndex[e1]++; + g->AdjMatIndex[e2]++; + numEdges++; + + while(fgets(string, MAX_REC_LEN,from )){ + if((string[0]==']') || (string[1]==']')) + break; + numEdges++; + e1 = atoi(string+startPos+9 ); + i=0; + while(string[i]!= 't') + i++; + int e2 = atoi(string+i+ 6); + g->AdjMatIndex[e1]++; + g->AdjMatIndex[e2]++; + } + for(int i = 0; i < numNodes; i++) + g->AdjMatIndex[i+1] += g->AdjMatIndex[i]; + + printf("No of Edges: %d\n",numEdges); + g->AdjMatVals = (int * ) malloc(2*numEdges*sizeof(int)); + g->edgeLen = (int * ) malloc(2*numEdges*sizeof(int)); + int * temp = (int * ) calloc((numNodes),sizeof(int)); + initGraph(g,numNodes); g->numEdges = 2*numEdges; + + fseek ( from, secFrom, SEEK_SET ); + while(fgets(string, MAX_REC_LEN,from )){ + + if((string[0]==']') || (string[1]==']')) + break; + e1 = atoi(string+startPos+9 ); + i=0; + while(string[i]!= 't') + i++; + int e2 = atoi(string+i+ 6); + g->AdjMatVals[g->AdjMatIndex[e1-1]+temp[e1-1]] = e2-1; + g->AdjMatVals[g->AdjMatIndex[e2-1]+temp[e2-1]] = e1-1; + g->edgeLen[g->AdjMatIndex[e1-1]+temp[e1-1]] = EDGE_LEN; + g->edgeLen[g->AdjMatIndex[e2-1]+temp[e2-1]] = EDGE_LEN; + temp[e1-1]++; + temp[e2-1]++; + } + free(temp); } Modified: csplugins/trunk/soc/ghuck/gpuGraphDrawing/simpleCUDPP.cu =================================================================== --- csplugins/trunk/soc/ghuck/gpuGraphDrawing/simpleCUDPP.cu 2009-06-11 22:55:06 UTC (rev 16933) +++ csplugins/trunk/soc/ghuck/gpuGraphDrawing/simpleCUDPP.cu 2009-06-11 23:32:46 UTC (rev 16934) @@ -331,7 +331,9 @@ { // Initialize device, using macro defined in "cutil.h" CUT_DEVICE_INIT(); - + + printf ("device initialized!\n"); + FILE* from; graph g; @@ -355,6 +357,8 @@ readGml(&g, from); else readChaco(&g, from); + + printf ("Finished reading graph!\n"); /* Initializations */ Modified: csplugins/trunk/soc/ghuck/gpuGraphDrawing/writeOutput.cu =================================================================== --- csplugins/trunk/soc/ghuck/gpuGraphDrawing/writeOutput.cu 2009-06-11 22:55:06 UTC (rev 16933) +++ csplugins/trunk/soc/ghuck/gpuGraphDrawing/writeOutput.cu 2009-06-11 23:32:46 UTC (rev 16934) @@ -16,9 +16,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. -See licence.h for more information. +See license.h for more information. **************************************************************************************/ -#include "licence.h" +#include "license.h" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "cytoscape-cvs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cytoscape-cvs?hl=en -~----------~----~----~----~------~----~------~--~---
