I have a directed acyclic graph with 194 vertices and 492 edges. I was able to get the 3-motifs without a problem. However, when I ran IGMotifsVertexParticipation I got an error message.

I ran the example from the documentation and received the same error message. The example has a small graph named g (which I can't see to copy).

I evaluated, from the example,

mot = IGMotifsVertexParticipation[g, 3]

I get an error message

LibraryFunction::fpexc: Numeric data containing a floating point exception (NaN or Inf) encountered.

I'm using Mathematica version 12.3.1 and IGraph/M version 0.5.1

I need help to resolve the error.

  • $\begingroup$ Next time please report bugs through the GitHub issue tracker: github.com/szhorvat/IGraphM/issues That ensures that I get notified. Here I may or may not notice your post. (Questions and support requests should be posted here, but not bug reports.) $\endgroup$
    – Szabolcs
    Aug 21, 2021 at 19:33

1 Answer 1


This is a bug in IGraph/M. Mathematica 12.2 changed how LibraryLink handles NaN/Inf values and I failed to update IGMotifsVertexParticipation for compatibility. IGraph/M 0.6, which should be out by the end of September the latest (if all goes well...) will fix this.

The problem affects only Mathematica 12.2 and later.

Luckily, there are easy workarounds:

  • Evaluate SetSystemOptions[ "LibraryLinkOptions" -> {"TestFloatingPointExceptions" -> False}] to disable checking for NaN/Inf values. This needs to be done every time after you restart the kernel.

  • For a more permanent solution, patch IGraph/M 0.5.1 (you will need to do this again if you re-install it!):

    • Open the relevant file using the command NotebookOpen@FileNameJoin[{ParentDirectory@DirectoryName@FindFile["IGraphM`"], "GraphMotifs.m"}]

    • Scroll down to the definition of IGMotifsVertexParticipation and find the line containing check@ig@"motifsParticipation".

    • Add expectInfNaN@ in front of check. The complete line should look like this:

      Round@Developer`FromPackedArray@expectInfNaN@check@ig@"motifsParticipation"[size, ConstantArray[0, size]]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.