Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine networks and provide multi-relation networks #98

Closed
bockthom opened this issue Feb 27, 2018 · 3 comments
Closed

Combine networks and provide multi-relation networks #98

bockthom opened this issue Feb 27, 2018 · 3 comments

Comments

@bockthom
Copy link
Collaborator

bockthom commented Feb 27, 2018

As already mentioned in #11, it would be helpful to have a function which combines networks and keeps edge types, node types and (possibly) attributes.

There are already some existing implementations to combine networks, but they either do not keep the edge types or node types (https://github.com/se-passau/dev-network-growth/blob/master/util.R#L64) or work only for disjoint networks (https://github.com/se-passau/codeface-extraction-r/blob/master/util-networks.R#L877). What we need is a universal function which can combine all kinds of networks and keeps all types (and possibly attributes).

As far as I know, @ecklbarb needs multi-edge-type networks, i.e., networks which consist of networks of different types. For example, think about author networks which contain cochange-based edges and mail-based edges together in one network. As one idea is to combine author networks with mail relation and author networks with cochange relation to achieve that goal, this is related to combining networks in general.

@ecklbarb Please keep us informed with your progress here.


As a side note, this issue is also somehow related to #15 (which could be based on the combine-networks function resulting from this issue).

@bockthom bockthom added this to the v3.2 milestone Feb 27, 2018
@clhunsen
Copy link
Collaborator

I talked to @ecklbarb about the construction of multi-edge-type networks, e.g., supporting several author.relation entries in the network configuration. We came up with a solution that, as we hope, will add solutions for the following problems in the end: multi-edge-type networks, combination of networks, and, therefore, multi-artifact networks (see #15).

Multi-edge-type networks

To support a network-configuration entry such as author.relation = c("mail", "cochange"), we need to carry out the following steps:

  1. Change the allowed number of arguments for the author.relation key to Inf here:
    https://github.com/se-passau/codeface-extraction-r/blob/0e90d6152c854766ec0f40496745508cf0e228fa/util-conf.R#L651-L656

  2. Split the function construct.network.from.list into two parts here:

    1. The first part of the function is the construction of an edgelist and a set of vertices. From the new function, we need to return a list of the following shape which is compatible with igraph::as.data.frame():

      network.df = list(
          edges = edge.list,
          vertices = data.frame(name = nodes.processed)
      )

      This way, we can transform the list to a network easily, using the function igraph::graph.data.frame().

    2. The second part of the function is the reliable construction of a network from the returned list of edges and vertices. We need to be sure to include the corner-cases we handle right now.

  3. In the function get.author.network, we need to build the network by looping over all given author.relation entries given through the network configuration.
    https://github.com/se-passau/codeface-extraction-r/blob/0e90d6152c854766ec0f40496745508cf0e228fa/util-networks.R#L493-L536

    There, we need to perform following steps to ensure the construction of the right network:

    1. Get the edgelist and the set of vertices for all configured relations.
    2. Merge the edge lists and the sets of vertices. We should rely here on the function merge, which should provide all functionality we need for the join operation. We need a separate function for that.
    3. Call the new function from point 2.ii to construct a network from the merged edgelists and vertices.

Combination of networks

When we implement point 3.ii in a public function somewhere in the networks module (e.g., right next to add.edges.for.bipartite.relation or so), we have easy play for the combination of networks here: We just need to add a function with a similar signature that just takes two (or more) networks as parameters and then performs the following steps:

  1. Call igraph::as.data.frame() to obtain lists as described in point 2.i above.
  2. Merge the result using the function from 3.ii.
  3. Call the function from point 2.ii above.

Multi-artifact networks

As the combination of networks also works for differing artifacts, we are safe here.

Transfer for other types of networks

These steps need to be performed also for artifact networks (solving the main idea from #15 this way), bipartite networks, and multi networks. We have to be careful with the bipartite relation especially.

@ecklbarb
Copy link
Contributor

We have to remember to adapt the simplify function to the multi-edge-type networks. Each edge type should be left after the simplification.

@clhunsen
Copy link
Collaborator

I suggest that we add the further improvements in another issue (i.e., merging of edge lists instead of networks here and here; and simplification on edge lists instead of networks here) and close this issue after merging of PR #115 for better bookkeeping.

@clhunsen clhunsen changed the title Combine networks and provide multi-edge-type networks Combine networks and provide multi-relation networks May 2, 2018
@clhunsen clhunsen mentioned this issue May 17, 2018
fehnkera pushed a commit to fehnkera/coronet that referenced this issue Sep 23, 2020
Now, it is possible to construct networks which include more than one
artifact and author relation.

To provide this functionality, the allowed number of the
'author.relation' and the 'artifact.relation'
is changed to Inf instead of 1.
A further edge attribute 'relation' is added to describe the relation
type. The functions 'get.artifact.network' and 'get.author.network' are
changed to handle more than one relation. Therefore, the functions
'get.bipartite.network' and 'get.multi.network' are adjusted, too. The
functions use the 'add.edges.for.bipartite.relations' function which can
handle more than one relation now.
To merge the networks of all relations, we add the functions
'merge.network.data' and 'merge.networks'. The function
'construct.network.from.list' is split into to functions
'construct.edge.list.from.key.value.list' and
'construct.network.from.edge.list'.

Solves the second part of se-sic#98.

Signed-off-by: Barbara Eckl <[email protected]>
Signed-off-by: Claus Hunsen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants