import org.projetorox.rox.graphapi.analysis.GraphUtils;
import org.projetorox.rox.graphapi.graph.IGraph;

//
// Application Startup entry point
//
public class StartApp {

	public static void main(String[] args) {

		try {

			// Carrega arquivo que contém o grafo
			IGraph oGraph1 = GraphUtils.getInstance().getGraph( "myGraph.graph" );
			IGraph oGraph2 = GraphUtils.getInstance().getGraph( "myGraph1.graph" );

			// Obtém matrizes de ajacência
			int oAdjGraph1[][] = GraphUtils.getInstance().getAdjacencyMatrix( oGraph1 );
			int oAdjGraph2[][] = GraphUtils.getInstance().getAdjacencyMatrix( oGraph2 );

			// Realiza análise
			IsomorphAnalysis oIsomorphAnalysis = new IsomorphAnalysis( oAdjGraph1, oAdjGraph2 );
			boolean bIsIsomorph = oIsomorphAnalysis.getResult();

			// Exibe as matriz1
			System.out.println( "The graph: " + oGraph1.getName() + " adjacency matrix is:" );
			for ( int x = 0; x < oAdjGraph1.length; x++  ) {

				for ( int y = 0; y < oAdjGraph1[x].length; y++  )
					System.out.print( " " + oAdjGraph1[x][y] );
				
				System.out.println();
				
			}

			// Exibe as matriz2
			System.out.println( "\nThe graph: " + oGraph2.getName() + " adjacency matrix is:" );
			for ( int x = 0; x < oAdjGraph2.length; x++  ) {

				for ( int y = 0; y < oAdjGraph2[x].length; y++  )
					System.out.print( " " + oAdjGraph2[x][y] );

				System.out.println();
				
			}

			// Exibe resultado
			System.out.println( "\nThe isomorph analysis result: " + bIsIsomorph );

			// Grafos são isomorfos?
			if ( bIsIsomorph ) {

				System.out.println( "\nThe vertex map ralationship: ");

				int aVertexMap[] = oIsomorphAnalysis.getVertexRelationshipMap();
				for ( int i = 0; i < aVertexMap.length; i++ )
					System.out.println( i + " -> " + aVertexMap[i] );

			}

		} catch ( Exception e ) {

			e.printStackTrace();

		}
	}
}
