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 380463
In Process

The Archive Base Latest Questions

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

This is a follow-up to the question ( Link ) What I intend on

  • 0

This is a follow-up to the question (Link)

What I intend on doing is using the XML to create a graph using NetworkX. Looking at the DOM structure below, all nodes within the same node should have an edge between them, and all nodes that have attended the same conference should have a node to that conference. To summarize, all authors that worked together on a paper should be connected to each other, and all authors who have attended a particular conference should be connected to that conference.

<conference name="CONF 2009">
<paper>
<author>Yih-Chun Hu(UIUC)</author>
<author>David McGrew(Cisco Systems)</author>
<author>Adrian Perrig(CMU)</author>
<author>Brian Weis(Cisco Systems)</author>
<author>Dan Wendlandt(CMU)</author>
</paper>
<paper>
<author>Dan Wendlandt(CMU)</author>
<author>Ioannis Avramopoulos(Princeton)</author>
<author>David G. Andersen(CMU)</author>
<author>Jennifer Rexford(Princeton)</author>
</paper>
</conference>

I’ve figured out how to connect authors to conferences, but I’m unsure about how to connect authors to each other. The thing that I’m having difficulty with is how to iterate over the authors that have worked on the same paper and connect them together.

    dom = parse(filepath)
    conference=dom.getElementsByTagName('conference')
    for node in conference:
        conf_name=node.getAttribute('name')
        print conf_name
        G.add_node(conf_name)

    #The nodeValue is split in order to get the name of the author 
#and to exclude the university they are part of

        plist=node.getElementsByTagName('paper')
        for p in plist:
            author=str(p.childNodes[0].nodeValue)
            author= author.split("(")
#Figure out a way to create edges between authors in the same <paper> </paper>

        alist=node.getElementsByTagName('author')
        for a in alist:
            authortext= str(a.childNodes[0].nodeValue).split("(")

            if authortext[0] in dict:
                edgeQuantity=dict[authortext[0]]
                edgeQuantity+=1
                dict[authortext[0]]=edgeQuantity
                G.add_edge(authortext[0],conf_name)

            #Otherwise, add it to the dictionary and create an edge to the conference.
            else:
                dict[authortext[0]]= 1
                G.add_node(authortext[0])
                G.add_edge(authortext[0],conf_name)
                i+=1
  • 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-12T14:59:30+00:00Added an answer on May 12, 2026 at 2:59 pm

    I’m unsure about how to connect authors to each other.

    You need to generate (author, otherauthor) pairs so you can add them as edges. The typical way to do that would be a nested iteration:

    for thing in things:
        for otherthing in things:
            add_edge(thing, otherthing)
    

    This is a naïve implementation that includes self-loops (giving an author an edge connecting himself to himself), which you may or may not want; it also includes both (1,2) and (2,1), which if you’re doing an undirected graph is redundant. (In Python 2.6, the built-in permutations generator also does this.) Here’s a generator that fixes these things:

    def pairs(l):
        for i in range(len(l)-1):
            for j in range(i+1, len(l)):
                yield l[i], l[j]
    

    I’ve not used NetworkX, but looking at the doc it seems to say you can call add_node on the same node twice (with nothing happening the second time). If so, you can discard the dict you were using to try to keep track of what nodes you’d inserted. Also, it seems to say that if you add an edge to an unknown node, it’ll add that node for you automatically. So it should be possible to make the code much shorter:

    for conference in dom.getElementsByTagName('conference'):
        var conf_name= node.getAttribute('name')
        for paper in conference.getElementsByTagName('paper'):
            authors= paper.getElementsByTagName('author')
            auth_names= [author.firstChild.data.split('(')[0] for author in authors]
    
            # Note author's conference attendance
            #
            for auth_name in auth_names:
                G.add_edge(auth_name, conf_name)
    
            # Note combinations of authors working on same paper
            #
            for auth_name, other_name in pairs(auth_names):
                G.add_edge(auth_name, otherauth_name)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just a follow up question to this one here => link Is it possible
This is a follow-up question related to my previous post . Below is a
This is like a follow-up question to this one . Basically what I'm doing
this is a follow on from this question and the link given it seems
Follow up to this question This (similar version from old link) works in SQL
My question is sort of a follow on from this question below but I
This question is a follow on to link text hence the revisited in the
This question is a follow up to the questions on link: Making a Movieclip
This is a follow up question to a previous question I asked about calculating
This is a follow-on question from the one I asked here . Can constraints

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.