1. Extraction Operators - PowerPoint PPT Presentation

About This Presentation
Title:

1. Extraction Operators

Description:

ADC 2002 (Extra) /department of mathematics and computer science. TU/e ... [A, name]='Dali'](e: expression) selects all the vertices that have an attribute ... – PowerPoint PPT presentation

Number of Views:20
Avg rating:3.0/5.0
Slides: 15
Provided by: flaviusf
Category:

less

Transcript and Presenter's Notes

Title: 1. Extraction Operators


1
1. Extraction Operators
  • Projection
  • Selection
  • Unorder
  • Join
  • Cartesian Product
  • Union
  • Difference
  • Intersection

set-like operators (commutativity)
2
  • Projection
  • ?type, name(e expression)
  • follows the edges of a given type and name
    from the input collection of vertices. The result
    is the collection of target vertices of the
    followed edges. The order of the output
    collection depends on the order of the input
    collection.
  • type E, A, R, D or disjunctions () of these
  • name regular expression over strings
  • Example. ?E, (Pp)ainters)(e) produces all
    the target vertices of element containment edges
    that have names starting with Painter, painter,
    Painters, or painters, and that originate from
    the vertices in e.

3
  • Selection
  • ?condition(e expression)
  • selects input collection vertices fulfilling
    the given condition. The order of the output
    collection depends on the order of the input
    collection.
  • In condition one can use projection operator,
    comparison operators (, lt, gt etc.), and logical
    operators (and, or, not).
  • Example. ??A, nameDali(e expression)
    selects all the vertices that have an attribute
    called name with the value Dali.

4
  • Unorder
  • ?(e expression)
  • unorders an input collection.
  • Unordering collections enables the definition of
    set-like (commutative) operators.
  • ?, ?, ?, ?, and ? are considering the order of
    the input collections in building the result.
    Unordering input collections enables the usage of
    their set-like variants (order is not important).
  • Two vertices are equal if they have the same
    value.

5
  • Join
  • (x expression) ?condition (y expression)
  • ?condition(x ? y)
  • the cartesian product is defined as two loops
    the external loop traverses the left input
    collection and the internal loop traverses the
    right input collection.
  • The pairs that fulfill the join condition
    form virtual vertices that have as outgoing
    edges, first the outgoing edges of the vertex
    from the left input collection and then the
    outgoing edges of the vertex from the right input
    collection preserving the original edge order.

6
  • Join (ctnd)
  • Example. (x ?E, person(people))
  • ??A, id(x) ?A, name(y)
  • (y ?E, painter(painters)) pairs
    person and painter vertices in virtual vertices
    based on the equality of the id attribute value
    of a person and the name attribute value of a
    painter.
  • Cartesian Product
  • (x expression) ? (y expression)
  • join without condition.

7
  • Difference
  • (x expression) ? (yexpression)
  • the result is a collection containing vertices
    that exist in first collection but not in second
    one preserving the original vertex order of the
    left input collection.
  • Intersection
  • (x expression) ? (yexpression)
  • the result is a collection containing vertices
    that exist in both input collections preserving
    the original vertex order of the left input
    collection.

8
  • Union
  • (x expression) ? (yexpression)
  • the result is a collection that contains first
    the left input collection, then the right input
    collection preserving the original vertex order.
  • It can be easily generalized to an n-ary
    operator.
  • Flexibility ensured by the fact that the input
    collections do not have to be union compatible
    as it was the case in relational algebra.

9
2. Meta-operators
  • Map
  • mapf(e expression)
  • applies a given function f to each element of
    the input collection. The function results are
    concatenated in the output collection.
  • All unary extraction operators have an inherent
    map operator associated to them. In the
    construction phase, the map operator is used
    explicitly to iterate not just over collection of
    vertices but also collection of edges.

10
  • Kleene Star
  • ?f(e expression)
  • repeats a given function f possibly infinite
    times starting with the given input collection.
    At each iteration the results of the function are
    added to the next function input. The order of
    the result collection depends on the order of the
    input collection and the recursion order.
  • Compared with the map operator it includes in the
    result the input collection.
  • When a fix point is reached (output input) the
    repetition stops.

11
3. Construction Operators
  • Create vertex
  • vertextype(value)
  • adds a new vertex with the given type and
    value to the graph.
  • Example. v1 vertexelement(null) creates a
    vertex of type element which has a new value (id)
    given by the system (by a skolem function) and
    v2 vertexstring(Dali) creates a vertex of
    type string and value Dali.

12
  • Create edge
  • edgetype, name, parent(child)
  • adds a new edge with a given type, name,
    parent, and child vertex to the graph.
  • Before inserting a new edge of type E, the
    resulting graph is checked for presence of loops
    among element containment edges.
  • If such a loop is formed the operation is
    unsuccessful.
  • Example. edgeE, painter, v1(v2) creates an edge
    of type E with name painter between two vertices
    (the vertices from the previous example).

13
Examples
  • Example. Copying a vertex v means creating a new
    vertex with the type and value of the original
    vertex vertextype(v)(value(v)).
  • Example. Copying an edge e, involves copying also
    the parent and children vertices
  • edgetype(e), name(e), vp(vc) where
  • vp vertextype(parent(e))(value(parent(e))
    , and
  • vc vertextype(child(e))(value(child(e))).

14
  • Example. Copying a complete graph starting from
    the vertex v can be done by copying all the graph
    edges and their associated vertices
  • mapedgetype(e), name(e),
  • vertextype(parent(e))(value
    (parent(e)))
  • (vertextype(child(e))(value
    (child(e))))
  • (e) where
  • e parentedge(?EAD, (child(x)))
  • (x parentedge(?EAD, (v)))
  • e represents all the edges in the original
    graph.
  • For each original vertex a unique new vertex
    is created using a skolem function.
Write a Comment
User Comments (0)
About PowerShow.com