public function getAncestryGraph($id)
    {
        $data = $this->getAncestry($id);

        if (count($data) == 0) {
            return [null, null];
        }

        // Create Vertices
        $this->vertices = $this->prepareVertices($data);

        // Create Graph
        $graph = new DirectedGraph();
        foreach ($this->vertices as $vertex) {
            $graph->add_vertex($vertex);
        }

        // Create Relations
        foreach ($data as $content) {
            $graph->create_edge($this->vertices[$content->parent_id], $this->vertices[$content->term_id]);
        }

        return [$this->vertices[$id], $graph];
    }
public function getAncestryGraph($id)
    {
        $data = $this->getAncestry($id);

        if (count($data) == 0) {
            return [null, null];
        }

        // Create Vertices
        $this->vertices = $this->prepareVertices($data);

        // Create Graph
        $graph = new DirectedGraph();
        foreach ($this->vertices as $vertex) {
            $graph->add_vertex($vertex);
        }

        // Create Relations
        foreach ($data as $content) {
            $graph->create_edge($this->vertices[$content->parent_id], $this->vertices[$content->term_id]);
        }

        return [$this->vertices[$id], $graph];
    }
public function getAncestryGraph ( $ id ) { $ data = $ this -> getAncestry ( $ id ) ; if ( count ( $ data ) == 0 ) { return [ null , null ] ; } // Create Vertices $ this -> vertices = $ this -> prepareVertices ( $ data ) ; // Create Graph $ graph = new DirectedGraph ( ) ; foreach ( $ this -> vertices as $ vertex ) { $ graph -> add_vertex ( $ vertex ) ; } // Create Relations foreach ( $ data as $ content ) { $ graph -> create_edge ( $ this -> vertices [ $ content -> parent_id ] , $ this -> vertices [ $ content -> term_id ] ) ; } return [ $ this -> vertices [ $ id ] , $ graph ] ; }
Get all parents recursively

@param int $id The term we want the ancestry from.
@return array Vertex, DirectedGraph
Get all parents recursively