Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7459165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T14:24:40+00:00 2026-05-29T14:24:40+00:00

I am trying to implement textrank algorithm for sentence extraction as described here .

  • 0

I am trying to implement textrank algorithm for sentence extraction as described here. For that in need to complement pagerank algorithm with weighted edges and get it to run on undirected graphs.
Networkx pagerank algorithm implementation allows me to easely integrate weighted edges and is said to convert directed graphs to undirected: see here.
However, when I tested it still seems to use directed graph. What am I missing here? Help greatly appriciated.

Example:

import networkx as nx
D=nx.DiGraph()
D.add_weighted_edges_from([('A','B',0.5),('A','C',1)])
print nx.pagerank(D)

Outpunt: {‘A’: 0.25974025929223499, ‘C’: 0.40692640737443164, ‘B’: 0.33333333333333331}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T14:24:41+00:00Added an answer on May 29, 2026 at 2:24 pm

    I think you misinterpreted the note on the networkx documentation. Though, I must admit it might be worded better.

    The PageRank algorithm was designed for directed graphs but this
    algorithm does not check if the input graph is directed and will
    execute on undirected graphs by converting each oriented edge in the
    directed graph to two edges.

    What this tells is that, PageRank algorithm is designed for directed graphs, but it can be used for undirected graphs. To do so, it converts the undirected network to a directed network by replacing each edge with two directed edges (in and out).

    Therefore, if you give it a directed network, it will calculate the PageRank according to the directed structure. So either start with an undirected network:

    import networkx as nx
    
    # Undirected Network
    D = nx.Graph()
    D.add_weighted_edges_from([('A', 'B', 0.5),('A', 'C', 1)])
    
    # Default max number of iterations failed to converge for me
    print nx.pagerank(D, max_iter=200)
    
    # Outputs:
    {'A': 0.48648648872844047, 'C': 0.32567567418103965, 'B': 0.18783783709051982}
    

    or if you already have a directed network, convert it to an undirected one:

    import networkx as nx
    
    # Directed Network
    D = nx.DiGraph()
    D.add_weighted_edges_from([('A', 'B', 0.5), ('A', 'C', 1)])
    
    # Convert to undirected
    G = D.to_undirected()
    
    # Default max number of iterations failed to converge for me
    print nx.pagerank(G, max_iter=200)
    
    # Outputs:
    {'A': 0.48648648872844047, 'C': 0.32567567418103965, 'B': 0.18783783709051982}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when trying to implement an Aspect, that is responsible for catching and logging a
Trying to implement some nested loops that are spitting out good old nested html
Trying to implement the excellent jQuery bidirectional infite scroll as explained here: http://www.bennadel.com/blog/1803-Creating-A-Bidirectional-Infinite-Scroll-Page-With-jQuery-And-ColdFusion.htm For
I trying to implement synchronization algorithm in C#, without success. Why isn't the following
SetFocus I'm trying implement the above Se Focus code in a Class Library that
Trying to implement AVAudioplayer and get some metering data of the played music, but
Trying to implement the example from here. Facebook Share passes along the URL of
Trying to implement a MSMQ-backed WCF PubSub. I understand that net.msmq is one-way; however
When trying to implement a simple OpenGL application, I was surprised that while it
Trying to implement a function that will return a list of ints the represent

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.