  Graph-level representation learning is important in a wide range of
applications. Existing graph-level models are generally built on i.i.d.
assumption for both training and testing graphs. However, in an open world,
models can encounter out-of-distribution (OOD) testing graphs that are from
different distributions unknown during training. A trustworthy model should be
able to detect OOD graphs to avoid unreliable predictions, while producing
accurate in-distribution (ID) predictions. To achieve this, we present SGOOD, a
novel graph-level OOD detection framework. We find that substructure
differences commonly exist between ID and OOD graphs, and design SGOOD with a
series of techniques to encode task-agnostic substructures for effective OOD
detection. Specifically, we build a super graph of substructures for every
graph, and develop a two-level graph encoding pipeline that works on both
original graphs and super graphs to obtain substructure-enhanced graph
representations. We then devise substructure-preserving graph augmentation
techniques to further capture more substructure semantics of ID graphs.
Extensive experiments against 11 competitors on numerous graph datasets
demonstrate the superiority of SGOOD, often surpassing existing methods by a
significant margin. The code is available at https://github.com/TommyDzh/SGOOD.
