Skip to content

Brokering Closure is moving

August 10, 2012

Dear readers, this blog is moving out from wordpress.com to a new location. The new address is http://bc.bojanorama.pl. Please update your bookmarks.

Drodzy czytelnicy, blog “Brokering Closure” wyprowadza się z wordpress.com pod nowy adres: http://bc.bojanorama.pl. Zaktualizujcie swoje linki/zakładki.

Correction to intergraph update

June 19, 2012

It turned out that I wrote the last post on “intergraph” package too hastily. After some feedback from CRAN maintainers and deliberation I decided to release the updated version of the “intergraph” package under the  original name (so no new package “intergraph0″) with version number 1.2. This version relies on legacy “igraph” version 0.5, which is now called “igraph0″. Package “intergraph” 1.2 is now available on CRAN.

Meanwhile, I’m working on new version of “intergraph”, scheduled to be ver. 1.3, which will rely on new version 0.6 of “igraph”.

I am sorry for the mess.

Updates to package ‘intergraph’

June 18, 2012

On June 17 a new version (0.6) of package “igraphwas released. This new version abandoned the old way of indexing graph vertices with consecutive numbers starting from 0. The new version now numbers the vertices starting from 1, which is more consistent with the general R convention of indexing vectors, matrices, etc. Because this change is not backward-compatible, there is now a separate package called “igraph0″ which still uses the old 0-convention.

These changes affect the package “intergraph“.

A new version of “intergraph” (ver 1.3) is being developed to be compatible with the new “igraph” 0.6. Until it is ready, there is now package “intergraph” version 1.2 available on CRAN, which still uses the old 0-convention. It relies on legacy version of “igraph” (version 0.5, now called “igraph0″ on CRAN).

To sum up:

  • If you have code that still uses the old version of “igraph” (earlier than 0.6) you should load package “igraph0″ instead of “igraph”, and use package “intergraph” version 1.2.
  • If you already started using the new version of “igraph” (0.6 or later), unfortunately you have to wait until a new version of “intergraph” (1.3) is released.

Edit

As I wrote in the next post, in the end there is no package “intergraph0″, just the new version 1.2. Consequently, I have edited the description above.

New and old news

May 24, 2012
tags:

PhD cover

It’s been a while since I wrote something, not without a reason. Last months were terribly busy for me. First of all, I defended my PhD (yay!). Second, a lot of my time was consumed by writing proposals. Third, upcoming changes to R package ‘igraph‘ caused an unscheduled but necessary review of some of my R packages. Nevertheless, I should be able get back to more regular blogging from now on.

For now three links from May:

  1. Wired now features a new blog (first post on January 7, 2012) devoted to social sciences called Social Dimension written by Samuel Arbesman. Recent interesting posts include:
  2. David Smith (Revolution Analytics) writes about recent EU High Court ruling in a case of SAS vs WPS. SAS is a data analytic software developed by SAS Institute and WPS is a low-cost clone of SAS capable of processing SAS data files and selected types of SAS scripts. The High Court ruled that “the programming languages cannot be copyrighted”. Here is the official press release.
  3. The Promising Future for Mathematical Sociology at ASA Math Sociology blog Permutations.

SNA with R workshop at Sunbelt XXXII in Redondo Beach

March 14, 2012

I am currently in Redondo Beach, CA at the Sunbelt XXXII social networks conference. The program is thick from numerous interesting talks so the event promises to be very interesting.

Today in the morning I gave the workshop “Introduction to Social Network Analysis with R”. Over 50 people registered. I am grateful to all the participants for attendance. I hope the workshop was useful to you, despite some of the technical difficulties in the beginning!

Here are some pictures:

Package ‘intergraph’ (1.1-0) released!

September 20, 2011

I just released the first official version of the ‘intergraph’ R package.

With the functions provided in the current version (1.1-0) you can convert network data objects between classes ‘igraph’ and ‘network’. The package supports directed and undirected networks, and handles the node, tie, and network (graph) attributes. Mutliplex networks (i.e., with possibly multiple ties per dyad) are also supported, although not thoroughly tested.

Network objects of class ‘network’ (from package “network”) can be used to store hypergraphs. Conversion of these is not supported at this time.

Both ‘igraph’ and ‘network’ classes can be used to explicitly deal with bipartite networks. Currently, for the bipartite networks, only the conversion from ‘igraph’ to ‘network’ will work. I hope to be able to add the conversion in the other direction in future releases.

You can download and install the package from CRAN. The package sources are hosted on R-Forge here.

Shortest paths to/from nodes of a certain type

September 14, 2011

Elijah asked the following via SOCNET mailing list:

I was wondering if anyone knew of a script or tool which would give me the network distance of nodes to a particular class of nodes.  I think of this as an Erdos number, except instead of getting the distance to one node, I want the distance to the closest node of a particular class.  Let’s say I have a network of people and I know their professions.  Some are Students, some are Journalists and a small number are Engineers.  I’d like to be able to find out the network distance of each node to the closest Engineer node. It would be particularly useful if the script also had the option to total edge weight into the calculation.

If you get your network data into R it is fairly straightforward to do this using igraph package. Here is the function:

# shortest paths to nodes with a specified value on certain node attribute
spnt <- function(g, aname, avalue, weights=NULL, ...)
{
  require(igraph)
  stopifnot(inherits(g, "igraph"))
  a <- get.vertex.attribute(g, aname)
  m <- shortest.paths(g, v=V(g)[a==avalue], weights=weights, ...)
  apply(m, 2, min)
}

It assumes that ‘g’ is a network (object of class ‘igraph’), ‘aname’ is a name of the node attribute, ‘avalue’ is the value of the attribute ‘aname’ that designates the nodes to/from which we would like to calculate distances, finally ‘weights’ can be optionally used to include weights in the calculation (as a numeric vector).

The function will return a vector of distances in ‘g’ from all the nodes to the closest node that have a value ‘avalue’ on attribute ‘aname’.

As an example consider the network below. It is undirected and has 15 nodes. It has two attributes defined: a node attribute called “color” having values “orange”, “lightblue”, and “lightgreen”, and an edge attribute called “w” with values 1 or 2. Both attributes are shown in the picture as a node color and edge label. The numbers on the nodes are node ids.

Assuming that the network is called ‘g’ we can use the function above in the following way:

> # from lightblue nodes to all others
> spnt(g, "color", "lightblue")
 [1] 0 1 2 1 2 3 0 1 2 1 2 3 2 3 4

> # from orange nodes to all others
> spnt(g, "color", "orange")
 [1] 1 0 1 0 1 0 1 0 0 2 1 0 2 1 0

> # to lightblue, but using weights (shortest path = minimal weight)
> spnt(g, "color", "lightblue", weights=E(g)$w)
 [1] 0 2 3 1 2 3 0 2 4 2 3 4 3 5 5

A couple of end notes:

  • In the result vector you will get 0s for the nodes of specified type, i.e. in the last example there are 0s for the “lightblue” nodes.
  • If a certain node is not connected (directly or via other nodes) to any node of specified type the vector will contain ‘Inf’ (plus infinity).
  • The algorithm will not accept negative weights. But this limitation can be effectively dodged by transforming the weights so that they are all positive (for example adding some number), performing the computation, and then transforming back the results to the original scale.
  • You can exploit other features of ‘shortest.paths’ function, on which this function is based. Any extra arguments to ‘spnt’ are passed to ‘shortest.paths’. For example, if the network is directed you can calculate shortest paths that are either incoming, or outgoing (via ‘mode’ argument). See help page of ‘shortest.paths’.
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: