Created
November 12, 2016 05:21
-
-
Save EntilZha/23c9a3b2e4d36208462ee1a2722a3675 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "preferential_attachment" | |
version = "0.1.0" | |
[dependencies] | |
rand = "0.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mod model; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate preferential_attachment; | |
use preferential_attachment::model; | |
fn main() { | |
println!("{}", model::hello()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate rand; | |
use rand::Rng; | |
pub fn hello() -> &'static str { | |
"hi" | |
} | |
pub struct Graph { | |
a: i32, | |
c: i32, | |
n: i32, | |
edges: Vec<i32> | |
} | |
pub fn build_graph(a: i32, c: i32, n: i32) -> Graph { | |
let phi = (c / (c + a)) as f32; | |
let mut rng = rand::thread_rng(); | |
for _ in 0..n { | |
if rng.gen::<f32>() < phi { | |
} else { | |
} | |
} | |
Graph { a: a, c: c, n: n, edges: Vec::new() } | |
} |
Author
EntilZha
commented
Nov 12, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment