public function getGraph($graph = true, $criteria = null, $cacheFlag = true) {
        /* graph is true, get all relations to max depth */
        if ($graph === true) {
            $graph = $this->xpdo->getGraph($this->_class);
        }
        /* graph is an int, get relations to depth of graph */
        if (is_int($graph)) {
            $graph = $this->xpdo->getGraph($this->_class, $graph);
        }
        /* graph defined as JSON, convert to array */
        if (is_string($graph)) {
            $graph= $this->xpdo->fromJSON($graph);
        }
        /* graph as an array */
        if (is_array($graph)) {
            foreach ($graph as $alias => $branch) {
                $fkMeta = $this->getFKDefinition($alias);
                if ($fkMeta) {
                    $fkCriteria = isset($fkMeta['criteria']) && isset($fkMeta['criteria']['foreign']) ? $fkMeta['criteria']['foreign'] : null;
                    if ($criteria === null) {
                        $query= array($fkMeta['foreign'] => $this->get($fkMeta['local']));
                        if ($fkCriteria !== null) {
                            $query= array($fkCriteria, $query);
                        }
                    } else {
                        $query= $this->xpdo->newQuery($fkMeta['class'], $criteria);
                        $addCriteria= array("{$query->getAlias()}.{$fkMeta['foreign']}" => $this->get($fkMeta['local']));
                        if ($fkCriteria !== null) {
                            $fkAddCriteria = array();
                            foreach ($fkCriteria as $fkCritKey => $fkCritVal) {
                                if (is_numeric($fkCritKey)) continue;
                                $fkAddCriteria["{$query->getAlias()}.{$fkCritKey}"] = $fkCritVal;
                            }
                            if (!empty($fkAddCriteria)) {
                                $addCriteria = array($fkAddCriteria, $addCriteria);
                            }
                        }
                        $query->andCondition($addCriteria);
                    }
                    $collection = $this->xpdo->call($fkMeta['class'], 'loadCollectionGraph', array(
                        &$this->xpdo,
                        $fkMeta['class'],
                        $branch,
                        $query,
                        $cacheFlag
                    ));
                    if (!empty($collection)) {
                        if ($fkMeta['cardinality'] == 'many') {
                            $this->_relatedObjects[$alias] = $collection;
                        } else {
                            $this->_relatedObjects[$alias] = reset($collection);
                        }
                    }
                }
            }
        } else {
            $graph = false;
        }
        return $graph;
    }