Code Monkey home page Code Monkey logo

phase-transition-graphs's Introduction

Grau-A-Projecte-T19

Transicio虂 de fase i components connexes en grafs aleatoris.

Recursos

Nota sobre GraphViz

Es necessari fer servir el motor NEATO per generar grafs on es tingui en compte la posici贸 dels nodes. D'altre manera els nodes es posicionen autom脿ticament.

Podeu instal路lar GraphViz al vostre PC (Linux) amb la comanda:

apt install graphviz

Per generar una imatge d'un graf podeu usar:

./graph OPCIONS | dot -Kneato -Tpng -o graph.png

Per exemple:

./graph rgg 32 0.3 -p | dot -Kneato -Tpng -o graph.png

Compilar i executar

El projecte es pot compilar amb un compilador de C++11 i Make (Linux). A continuaci贸 un exemple amb una distribuci贸 basada en Debian.

apt install build-essential
make

Aqu铆 teniu un altre exemple amb una distribuci贸 basada en ArchLinux:

sudo pacman -S gcc make r --needed --noconfirm
make

A continuaci贸 us posem la ajuda d'execuci贸.

Usage:
        ./graph test
        ./graph brg n p [OPTIONS]
        ./graph rgg n r [OPTIONS]

Where n is the amount of vertex (natural number), and p and r are decimal numbers in the range 0-1, or intervals wiritten in the form low:hight:step

Options:
 -p         (Default) Print the graph.
 -c         Print the number of connected componenets.
 -c k       Like C but do it k times and output a CSV space separated table.
 -s         Print the size of the maximum connected component.
 -s k       Like S but do it k times and output a CSV space separated table.
 -k         Print whether the graph is complete or not.
 -k k       Like K but do it k times and output a CSV space separated table.
 -r         Print whether the graph is regular or not.
 -r k       Like R but do it k times and output a CSV space separated table.

Per exemple, per generar una llista del n煤mero de components conexes dels grafs de mida 20 en el model binomail des de p=0, fins a p=0.5 amb un increment de 0.005 a cada iteraci贸 es pot fer amb la seguent commanda:

./graph brg 20 0.0:0.5:0.005 -c

Generar els grafics de linies

El codi en R utilitzat ha estat el seguent (adaptat a cada cas):

mydf <- read.table("brg1.csv", sep=" ")
b <- sapply(mydf, function (x) as.integer(x>1))
x <- seq(0,0.99999,0.001)
v <- rowMeans(b[,-101])

plot(x,v, type = "l",xlab="p",ylab="")

Per a general el grafic del despla莽ament de la transici贸 de fase el codi es el seguent:

filelist <- list.files(pattern="*.csv")
library(gtools)
filelist <- mixedsort(filelist)

thecenter <- function(filepath) {
  mydf <- read.table(filepath, sep=" ")
  b <- sapply(mydf, function (x) as.integer(x<=1))
  x <- seq(0,999)
  v <- rowMeans(b[,-1001])
  z <- sapply(v, function (x) 0.5-abs(x-0.5))
  z <- smooth(z, "3RSS")
  m <- mean(which(z==max(z)))
  #plot(z, type = "l", xlab="% of p",ylab="")
  return(m)
}

x <- thecenter("t-brg5.csv")
print(filelist)
b <- sapply(filelist, function (x) thecenter(x))
s <- seq(5,100,5)
plot(s, b, type = "l", ylab="% of p", xlab="N")

Authors

phase-transition-graphs's People

Contributors

arnauruana avatar elmeunick9 avatar thesorahd avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    馃枛 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 馃搳馃搱馃帀

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google 鉂わ笍 Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.