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 shadow#26
  • Loading branch information
sporksmith committed Jul 7, 2022
1 parent 6d6ca32 commit e352970
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 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/)
8 changes: 6 additions & 2 deletions src/tgen-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

#include "tgen.h"

#if IGRAPH_VERSION_MAJOR==0 && IGRAPH_VERSION_MINOR<9
#define igraph_set_attribute_table igraph_i_set_attribute_table
#endif

typedef enum {
TGEN_A_NONE = 0,
TGEN_EA_WEIGHT = 1 << 1,
Expand Down Expand Up @@ -1271,7 +1275,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 +1295,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

0 comments on commit e352970

Please sign in to comment.