Monday, 4 April 2016

Graphs that are betweenness and/or degree-regular

All connected graphs on between 3 and 8 vertices that have identical betweenness values for all vertices:

is.generic.regular <- function(g, centrality.func, tol = 1E-10){
  centrals <- centrality.func(g)
  diffs <- abs(centrals - centrals[1])
  sum(diffs) < tol
  }

is.beta.regular <- function(g, tol = 1E-10){
  # checks if all the betweenness values for a graph
  # are equal (that is, less than a specified tolerance)
  is.generic.regular(g, betweenness, tol)
  }

is.delta.regular <- function(g, tol = 1E-10){
  # checks if all the degree values for a graph are equal
  # - tolerance should be irrelevant since degrees are integers
  is.generic.regular(g, degree, tol)
  }

##############################################

# All non-isomorphic connected graphs on up to 8 vertices
all.graphs <- lapply(1:8, function(i){
  Filter(is.connected, make_all_graphs(i))
  })

##############################################

# The subset of graphs that are betweenness-regular
beta.regs <- lapply(all.graphs,
  function(G.list){
    Filter(is.beta.regular, G.list)
    })
sapply(beta.regs, length)
#[1] 1 1 1 2 2 5 3 8

# The subset of graphs that are regular (ie, degree-regular)
delta.regs <- lapply(all.graphs,
  function(G.list){
    Filter(is.delta.regular, G.list)
    })
sapply(delta.regs, length)
# [1]  1  1  1  2  2  4  4 13

# The subset of graphs that are regular for both centralities
beta.and.delta.regs <- lapply(beta.regs, function(G.list){
  Filter(is.delta.regular, G.list)
  })
sapply(beta.and.delta.regs, length)
# [1] 1 1 1 2 2 4 3 7
par(mfrow = c(2, 4))
lapply(beta.and.delta.regs[[8]], plot)
# Some examples on 8 vertices:


# The subset of graphs that are betweeness-regular but not degree regular
beta.not.delta.regs <- lapply(beta.regs, function(G.list){
  Filter(function(g) !is.delta.regular(g), G.list)
  })
# [1] 0 0 0 0 0 1 0 1
par(mfrow = c(1, 2))
plot(beta.not.delta.regs[[6]][[1]])
plot(beta.not.delta.regs[[8]][[1]])


# The subset of graphs that are degree- but not betweenness-regular
delta.not.beta.regs <- lapply(delta.regs, function(G.list){
  Filter(function(g) !is.beta.regular(g), G.list)
  })
sapply(delta.not.beta.regs, length)

#[1] 0 0 0 0 0 0 1 6
par(mfrow = c(2, 4))
plot(delta.not.beta.regs[[7]][[1]])
lapply(delta.not.beta.regs[[8]], plot)


No comments:

Post a Comment