function [G,V,E] = LEM_lanes2graph(lanes)
%

G = [];

if isempty(lanes)
    return
end

[num_lanes,~] = size(lanes);
V = [];
E = [];
num_V = 0;

for n = 1:num_lanes
    x1 = lanes(n,1);
    y1 = lanes(n,2);
    z1 = lanes(n,3);
    x2 = lanes(n,4);
    y2 = lanes(n,5);
    z2 = lanes(n,6);
    if isempty(V)
        V = [V; x1,y1,z1];
        V = [V; x2,y2,z2];
        [num_V,~] = size(V);
        ind1 = num_V - 1;
        ind2 = num_V;
    else
        ind1 = find(V(:,1)==x1&V(:,2)==y1&V(:,3)==z1);
        ind2 = find(V(:,1)==x2&V(:,2)==y2&V(:,3)==z2);
        if isempty(ind1)
            V = [V; x1,y1,z1];
            [num_V,~] = size(V);
            ind1 = num_V;            
        end
        if isempty(ind2)
            V = [V; x2,y2,z2];
            [num_V,~] = size(V);
            ind2 = num_V;
        end
    end
    E = [E; ind1,ind2];
end
[num_E,~] = size(E);
A = zeros(num_V,num_V);
for k = 1:num_E
    A(E(k,1),E(k,2)) = 1;
end

G = digraph(A);
