Skip to content

Commit

Permalink
Handle rename of igraph_i_set_attribute_table in igraph 0.9.0
Browse files Browse the repository at this point in the history
Fixes #26
  • Loading branch information
sporksmith committed Jul 7, 2022
1 parent 0b05787 commit 3573c08
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ find_package(M REQUIRED)
pkg_check_modules(IGRAPH REQUIRED igraph)
pkg_check_modules(GLIB REQUIRED glib-2.0)

## Parse out igraph version. Needed to work around breaking API changes in igraph.
string(REPLACE "." ";" IGRAPH_VERSION_LIST ${IGRAPH_VERSION})
list(GET IGRAPH_VERSION_LIST 0 IGRAPH_VERSION_MAJOR)
list(GET IGRAPH_VERSION_LIST 1 IGRAPH_VERSION_MINOR)
list(GET IGRAPH_VERSION_LIST 2 IGRAPH_VERSION_PATCH)
add_definitions(-DIGRAPH_VERSION_MAJOR=${IGRAPH_VERSION_MAJOR})
add_definitions(-DIGRAPH_VERSION_MINOR=${IGRAPH_VERSION_MINOR})
add_definitions(-DIGRAPH_VERSION_PATCH=${IGRAPH_VERSION_PATCH})

## recurse our project tree
add_subdirectory(${CMAKE_SOURCE_DIR}/src/)
add_subdirectory(${CMAKE_SOURCE_DIR}/test/)
5 changes: 3 additions & 2 deletions src/tgen-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <igraph.h>

#include "tgen.h"
#include "tgen-igraph-compat.h"

typedef enum {
TGEN_A_NONE = 0,
Expand Down Expand Up @@ -1271,7 +1272,7 @@ TGenGraph* tgengraph_new(gchar* path) {
* uses dlmopen to get a private namespace for each plugin. */

/* use the built-in C attribute handler */
igraph_attribute_table_t* oldHandler = igraph_i_set_attribute_table(&igraph_cattribute_table);
igraph_attribute_table_t* oldHandler = igraph_set_attribute_table(&igraph_cattribute_table);

g->graph = _tgengraph_loadNewGraph(g->graphPath);
if(!g->graph) {
Expand All @@ -1291,7 +1292,7 @@ TGenGraph* tgengraph_new(gchar* path) {
}

/* replace the old handler */
igraph_i_set_attribute_table(oldHandler);
igraph_set_attribute_table(oldHandler);
}

if(error) {
Expand Down
13 changes: 13 additions & 0 deletions src/tgen-igraph-compat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* See LICENSE for licensing information
*/

#ifndef TGEN_IGRAPH_COMPAT_H_
#define TGEN_IGRAPH_COMPAT_H_

/* Renamed in in igraph 0.9.0 */
#if IGRAPH_VERSION_MAJOR==0 && IGRAPH_VERSION_MINOR<9
#define igraph_set_attribute_table igraph_i_set_attribute_table
#endif

#endif
3 changes: 2 additions & 1 deletion src/tgen-markovmodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <igraph.h>

#include "tgen-igraph-compat.h"
#include "tgen-log.h"
#include "tgen-markovmodel.h"

Expand Down Expand Up @@ -881,7 +882,7 @@ static igraph_t* _tgenmarkovmodel_loadGraph(FILE* graphFileStream, const gchar*
igraph_t* graph = g_new0(igraph_t, 1);

/* make sure we use the correct attribute handler */
igraph_i_set_attribute_table(&igraph_cattribute_table);
igraph_set_attribute_table(&igraph_cattribute_table);

result = igraph_read_graph_graphml(graph, graphFileStream, 0);

Expand Down

0 comments on commit 3573c08

Please sign in to comment.