/* !-------------------------------------------------------------------------! ! ! ! N A S G R I D B E N C H M A R K S ! ! ! ! J A V A V E R S I O N ! ! ! ! D G R A P H ! ! ! !-------------------------------------------------------------------------! ! ! ! DGraph implements rudimentary Directed Graph. ! ! ! ! Permission to use, copy, distribute and modify this software ! ! for any purpose with or without fee is hereby granted. ! ! We request, however, that all derived work reference the ! ! NAS Grid Benchmarks 3.0 or GridNPB3.0. This software is provided ! ! "as is" without expressed or implied warranty. ! ! ! ! Information on GridNPB3.0, including the concept of ! ! the NAS Grid Benchmarks, the specifications, source code, ! ! results and information on how to submit new results, ! ! is available at: ! ! ! ! http://www.nas.nasa.gov/Software/NPB ! ! ! ! Send comments or suggestions to ngb@nas.nasa.gov ! ! Send bug reports to ngb@nas.nasa.gov ! ! ! ! E-mail: ngb@nas.nasa.gov ! ! Fax: (650) 604-3957 ! ! ! !-------------------------------------------------------------------------! ! GridNPB3.0 Java version ! ! M. Frumkin ! !-------------------------------------------------------------------------! */ package tasks.DGraph; import java.io.*; import java.text.*; import java.awt.*; import java.util.*; public class DGraph implements Serializable{ int maxNodes; int maxArcs; public int id; public String name; public int numNodes; public int numArcs; public DGNode node[]; public DGArc arc[]; int BLOCK_SIZE = 128; public DGraph(String nm){ name=nm; maxNodes=BLOCK_SIZE; maxArcs=BLOCK_SIZE; node=new DGNode[maxNodes]; arc=new DGArc[maxArcs]; } public int AttachNode(DGNode nd){ int i,j; if (numNodes == maxNodes ) { maxNodes += BLOCK_SIZE; DGNode tmpndar[]=new DGNode[maxNodes]; for(i=0;i < numNodes; i++) tmpndar[i]=node[i]; node=tmpndar; } for ( i = 0; i < numNodes; i++) { DGNode tmpnd = node[i]; if ( tmpnd.name.length() != nd.name.length() ||nd.name.indexOf(tmpnd.name)<0) continue; if ( nd.inDegree > 0 ) { if(tmpnd.inDegree+nd.inDegree>tmpnd.maxInDegree){ tmpnd.maxInDegree += nd.maxInDegree; DGArc tmparcar[]=new DGArc[tmpnd.maxInDegree]; for(j=0;j 0 ) { if(tmpnd.outDegree+nd.outDegree>tmpnd.maxOutDegree){ tmpnd.maxOutDegree += nd.maxOutDegree; DGArc tmparcar[]=new DGArc[tmpnd.maxOutDegree]; for(j=0;j= 2) { for(int j = 0; j < focusNode.inDegree; j++ ) { focusNode.inArc[j].tail.Show(); } } System.out.print("*\t"); focusNode.Show(); if(DetailsLevel < 2) continue; for(int j = 0; j < focusNode.outDegree; j++ ) { focusNode.outArc[ j].head.Show(); } System.out.println("---"); } return; } }