GithubHelp home page GithubHelp logo

ivana818 / random-walk-undirected-graph Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3 KB

Simulate random walk and calculate ℓ1-distance between normalized degree vector and empirical frequency vector

Python 100.00%
l1-normalization random-walk undirected-graph big-data empirical-frequency-vector normalized-degree-vector graph

random-walk-undirected-graph's Introduction

Random Walk Simulation on Undirected Graph - L1 Distance between Normalized Degree Vector and Empirical Frequency Vector

This is to simulate a random walk on an undirected graph and calculate the ℓ1-distance between normalized degree vector and empirical frequency vector during the random walk.

Parameters

  • graph : networkx.classes.graph.Graph
       An undirected nxGraph with at least one edge for all node
  • steps : integer
       Number of steps to walk in random walk stimulation

Returns

  • distance : float
       ℓ1-distance between normalized degree vector and empirical frequency vector

Preprocessing Examples

If the undirected graph is not nxGraph, we have to convert it to a nxGraph before apply random_walk
If it is presented in a dictionary

>>> print(undirected_graph)
{0:[1, 2, 4], 1:[2, 3], 2:[3], 3:[4], 4:[5, 6]}

We can convert it to nxGraph as follows

graph = nx.Graph()
number_of_edges = sum([len(undirected_graph[i]) for i in undirected_graph if isinstance(undirected_graph[i], list)])
for i in undirected_graph:
    for j in range(len(undirected_graph[i])):
        graph.add_edge(i,undirected_graph[i][j])

random-walk-undirected-graph's People

Watchers

 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.