Skip to content

Instantly share code, notes, and snippets.



Created Nov 12, 2016
What would you like to do?
name = "preferential_attachment"
version = "0.1.0"
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 {
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() }

This comment has been minimized.

Copy link
Owner Author

@EntilZha EntilZha commented Nov 12, 2016

$ 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/
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/
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