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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:05:54+00:00 2026-05-31T06:05:54+00:00

I have an N x 2 table of integers called games[ , ]. The

  • 0

I have an N x 2 table of integers called games[ , ]. The table of nodes/edges is converted to a graph:

net <- graph.data.frame(as.data.frame(games), directed=FALSE)
deg.net <- degree(net, mode='total', loops=FALSE) 

(I realize that not all options are necessary.)

The problem I am having is that the degree distribution seems to be for in-degree only. For example, the games file has the lines:

103 86
24 103
103 2
92 103
87 103
103 101
103 44

and yet igraph indicates that the degree for node 103 is ‘3’ when it should be ‘7’.

Any insight in what I am missing would be appreciated.

  • 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-31T06:05:55+00:00Added an answer on May 31, 2026 at 6:05 am

    One thing that you should keep in mind is that most igraph functions refer to the vertices by their IDs, which are simply integers from 0 to N-1 where N is the number of vertices in the graph. If you have an N x 2 table of integers (containing zero-based vertex indices) and you want igraph to use the integers as the vertex IDs, you can simply use the graph constructor after having flattened the matrix into a vector by rows. When you use graph.data.frame, the first two columns of the data frame are assumed to contain symbolic vertex names (i.e. there is no requirement that they must be integers); these will be assigned to the name vertex attribute, and igraph will simply make up the IDs from 0 to N-1.

    So, let’s assume that you have an N x 2 matrix, one row per each edge:

    > edges <- matrix(c(103, 86, 24, 103, 103, 2, 92, 103, 87, 103, 103, 101, 103, 44), ncol=2, byrow=T)
    

    First we create a graph out of it after flattening the matrix by rows:

    > g <- graph(as.vector(t(edges)))
    

    This gives you a directed graph with 7 edges and the out/in-degrees of vertex 103 will be as expected:

    > ecount(g)
    7
    > degree(g, 103, mode="out")
    4
    > degree(g, 103, mode="in")
    3
    > degree(g, 103, mode="all")
    7
    

    If you use graph.data.frame with the above matrix, igraph will construct a graph where the numbers in the matrix are stored in the name vertex attribute:

    > g <- graph.data.frame(as.data.frame(edges))
    > V(g)$name
    [1] "103" "24"  "92"  "87"  "86"  "2"   "101" "44"
    

    This shows you that the vertex with the name 103 actually became vertex zero in the graph:

    > degree(g, 0, mode="out")
    4
    > degree(g, 0, mode="in")
    3
    > degree(g, 0, mode="all")
    7
    

    As far as I know, degree is also able to work with the vertex names directly if there is a vertex attribute called name in the graph, so you can also do this:

    > degree(g, "103", mode="in")
    3
    

    Hope this helps.

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

Sidebar

Related Questions

I have a table called matches with these 4 fields (all are integers): 1.id
I have a table called games in which will have games.id, games.name and games.modus
I have a table called Request and data will be entered by two types
I have a table that I select data from with a column called parent
In database table I have column called options . It has type of integer
I have a varchar(100) column in a table that contains a mix of integers
I have a table called Shoppings in my SQL db. This one has a
I have a table in MS SQL Server 2008 with a varchar column called
I have a simple SQLite table called message: sequence INTEGER PRIMARY KEY type TEXT
I have this Entity called 'Operation': @Entity @Table(name=operation) public class Operation implements Serializable {

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.