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

  • Home
  • SEARCH
  • 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 4239542
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:02:55+00:00 2026-05-21T03:02:55+00:00

The equation for Network Modularity is given on its wikipedia page (and in reputable

  • 0

The equation for Network Modularity is given on its wikipedia page (and in reputable books). I want to see it working in some code. I have found this is possible using the modularity library for igraph used with R (The R Foundation for Statistical Computing).

I want to see the example below (or a similar one) used in the code to calculate the modularity. The library gives on example but it isn’t really what I want.

Let us have a set of vertices V = {1, 2, 3, 4, 5} and edges E = {(1,5), (2,3), (2,4), (2,5) (3,5)} that form an undirected graph.

Divide these vertices into two communities: c1 = {2,3} and c2 = {1,4,5}. It is the modularity of these two communities that is to be computed.

  • 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-21T03:02:56+00:00Added an answer on May 21, 2026 at 3:02 am
    library(igraph)
    g <- graph(c(1,5,2,3,2,4,2,5,3,5))
    membership <- c(1,2,2,1,1)
    modularity(g, membership)
    

    Some explanation here:

    1. The vector I use when creating the graph is the edge list of the graph. (In igraph versions older than 0.6, we had to subtract 1 from the numbers because igraph uses zero-based vertex indices at that time, but not any more).

    2. The i-th element of the membership vector membership gives the index of the community to which vertex i belongs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this equation: f(a,b,x)=t0-a+(a^2*(1+((x-x0)^2/b^2)))^0.5 if I want get the first derivative: df(a,b,x)/d(a,b) for
I want to write a command to display equation of robot position and its
I have been working on a math equation for 2 days. The whole process
i want the result of an equation rounded to the nearest integer. e.g. 137
Trying to figure out an equation to get the current group a page would
I'm refactoring a 500-lines of C++ code in main() for solving a differential equation.
I have a small desktop Twitter client written in VB.NET (2.0). Works great. Some
This equation works good? Ruby on Rails + Cassandra on Netbeans6.9? I have try
I have an equation for a parabolic curve intersecting a specified point, in my
I have the equation y = 3(x+1)^2 + 5(x+1)^4. Using Horner's scheme I could

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.