Skip to content

Instantly share code, notes, and snippets.

@EntilZha
Created November 12, 2016 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EntilZha/23c9a3b2e4d36208462ee1a2722a3675 to your computer and use it in GitHub Desktop.
Save EntilZha/23c9a3b2e4d36208462ee1a2722a3675 to your computer and use it in GitHub Desktop.
[package]
name = "preferential_attachment"
version = "0.1.0"
[dependencies]
rand = "0.3"
mod model;
extern crate preferential_attachment;
use preferential_attachment::model;
fn main() {
println!("{}", model::hello());
}
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() }
}
@EntilZha
Copy link
Author

$ cargo build
   Compiling libc v0.2.17
   Compiling rand v0.3.14
   Compiling preferential_attachment v0.1.0 (file:///Users/pedro/Documents/Code/network-models/hw6/preferential_attachment)
error[E0432]: unresolved import `rand::Rng`
 --> src/model.rs:3:5
  |
3 | use rand::Rng;
  |     ^^^^^^^^^ Did you mean `self::rand`?

error: no method named `gen` found for type `model::rand::ThreadRng` in the current scope
  --> src/model.rs:20:16
   |
20 |         if rng.gen::<f32>() < phi {
   |                ^^^
   |
   = help: items from traits can only be used if the trait is in scope; the following trait is implemented but not in scope, perhaps add a `use` for it:
   = help: candidate #1: `use model::rand::Rng`

error: aborting due to previous error

error: Could not compile `preferential_attachment`.

To learn more, run the command again with --verbose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment