Thank you very much, I tried to convert the following code in perl language, and as an example introduce the number 4 in "Indica el numero de nodos" and introduce the following secuence of numbers in the section "Introduzca las conecciones de los nodos": 1, 1, 1, 1, 0, 0, 1, 0,1, 1, 0, 1.

I expect to obtain as a result :

" la posicion del nodo en escala vector, numero de aristas y coeficiente de clustering respectivamente:"

0

3

2/3

" la posicion del nodo en escala vector, numero de aristas y coeficiente de clustering respectivamente:"

1

2

3

" la posicion del nodo en escala vector, numero de aristas y coeficiente de clustering respectivamente:"

2

2

3

" la posicion del nodo en escala vector, numero de aristas y coeficiente de clustering respectivamente:"

3

3

2/3

#include <stdio.h> #include <stdlib.h> int main(int argc, char** argv){ int nodos, n,i, j, l; float aristas, areales, clust; aristas=0; printf("Indica el numero de nodos\n");//En este bloque es donde se + recopila toda la informacion para hacer el calculo de conectividad y + coeficiente de clustering. scanf("%d",&nodos); int red[nodos][nodos];//aqui se declara la matriz una vez que se s +abe el numero de nodos printf("Introduzca las conecciones de los nodos.\n"); for(n=0; n<nodos; n++){ for(i=0; i<nodos; i++){ if(n!=i){ scanf("%d",&red[n][i]); } } } for(n=0; n<nodos; n++){//Este bloque cuenta el número de coneccion +es de cada nodo (aristas). aristas=0; for(i=0; i<nodos; i++){ if(n!=i){ if(red[n][i]==1){ aristas++; } } } printf(" la posicion del nodo en escala vector, numero de aris +tas y coeficiente de clustering respectivamente:\n"); printf("%d\n",n); printf("%f\n",aristas); if(aristas==1||aristas==0){ printf("0\n"); } else{ areales=0; for(j=0; j<nodos; j++){ if(n!=j){ for(l=0; l<nodos; l++){ if(j!=l&&l!=n){ if(red[j][l]==1){ areales++; } } } } } areales=areales/2; clust=(2*areales)/(aristas*(aristas-1)); printf("%f\n",clust); } } }

In reply to Re^2: help :) by Harry_Sor
in thread help :) by Harry_Sor

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.