viernes, 16 de octubre de 2009

Java Graph Package

This Java Class provide an interface to work with graphs (Direct an Undirect raphs). You can get output format to generate "bmp" graphs with Graphviz.



Step sample:


1. Import class


2. Code



3. Get results




4. Generate graph with output String Graphviz




jueves, 27 de agosto de 2009

Floyd algorithm

The problem: We have a Graph, no direct and valued, also, we have a vector with N stages. For example, one stage is between nodes 2 and 5, other stage is between nodes 5 and 1 , ect ...
We need the minimun path between first stage and last stage through the middle stages in order.

The solution: We use, Floyd algorithm.

The graph:


The stages :



The output:


miércoles, 22 de abril de 2009

I propose new algorithm problem about rated digraphs

The goal: We should get the minimun value way betwen two nodes, with follows constrains:

  1. * The total path value is the sum of the edges in the A->B direction plus double value of B->A direction (if exists) .
  2. The graph it´s representated by a adjacency matrix .

A graph example :



One possible solution is: 1->2->3->4 with total path value* 10 (1->2 [4] 2->3 [5] 3->4 [10])

Download pascal code
(You need stack estructure [easy to computer engineer ;)])

viernes, 10 de abril de 2009

Java Random Double in Range Generation

Estos días he estado pensando sobre como generar números aleatorios en Java dentro de un rango, pues bien, aquí esta mi solución y su análisis:



Así, analizando los valores límite, observamos:

max(0.0)+min(1-(0.0)) => min
max(0.5)+min(1-(0.5)) => (max+min)/2
max(1.0)+min(1-(1.0)) => max

De una manera gráfica, observamos como los valores están siempre encerrados dentro de los límites:


Un análisis matemático de ajuste.

Aquí un histograma con 100000 valores generados aleatoriamente, se puede observar como sigue una distribución uniforme.

Con un rango en la escala negativa.