精华内容
下载资源
问答
  • <p>This change is <a href="https://reviewable.io/reviews/gfx-rs/gfx/1750"><img src=...该提问来源于开源项目:gfx-rs/gfx</p></div>
  • vertex coverapproximation factor(近似比)maximum matching&&minimum vertex covermaximum matching(最大匹配)vertex cover(点覆盖) approximation factor(近似比) 近似比是近似算法所得的近似解与...

    approximation factor(近似比)

    近似比是近似算法所得的近似解与最优解OPT的比值。我们想用近似算法找到NP问题的近似解,需要通过近似比来论证近似算法的优秀。但是,对于NP问题,我们找不到OPT,又如何得到近似比呢?
    这里涉及到近似算法中求近似比的通用原则,让我们不知道OPT也可以求近似比,即先求OPT的下界,再找到一个近似算法,要求这个算法能求得与下界成常数倍关系的近似解。比如,OPT≥a,c·OPT≥c·a;那么我们需要找到一个近似算法求得近似解c·a,此时有c·a/OPT≤c·OPT/OPT=c,我们称近似比为c。

    maximum matching&&minimum vertex cover

    maximum matching(最大匹配)

    matching:匹配。给定一个图H =(U,F),一个边集M ⊆ F,如果M中没有两条边共享一个端点,即M中任意两条边都不交于一个点,那么M被称为是一个匹配。
    maximum matching:最大匹配。最大基数匹配,即这样的匹配可以找到的匹配边数是最多的。
    在这里插入图片描述
    maximal matching:极大匹配。我们不能再找到图H中的任何一条边,添加到匹配中仍满足匹配条件。
    在这里插入图片描述

    vertex cover(点覆盖)

    给定一个无向图G=(V,E), 有一个成本函数:V→ Q+,找到最小成本点覆盖,即一个集合V’⊆ V,对于V’,G中每条边至少有一个端点在V’中,这样的V’就是一个点覆盖,我们要找到最小的点集V’,即最小成本点覆盖。在所有点都是单位成本的情况下,我们称点覆盖问题为基数点覆盖问题。(这本书定义的“点覆盖”直接是最小成本点覆盖,这个问题还没有被证明是NP问题。)

    approximate algorithm on vertex cover(点覆盖问题的近似算法)

    approximate algorithm(近似算法)

    先找OPT下界:极大匹配提供了点覆盖问题的下界

    极大匹配:如果再加任意一条边到匹配中,那么一定会有至少一条边与新加入的边交于一个点。
    下界:任何的点覆盖都不得不至少选择每个极大匹配边的一个端点。

    • 我们按照极大匹配把一个图分成匹配边和未匹配边,那么任意一个点覆盖必定包含匹配边的一个端点,不然这个点覆盖就无法覆盖这个匹配边,那么就不是一个点覆盖。
    • 如果不是所有匹配边和未匹配边都交于一个点的话,点覆盖还需要包含未匹配边的端点,那么点覆盖的点集的点的数目必定是大于等于极大匹配的边集的边的数目。(如下图,即不是匹配边和未匹配边都交于一个点。)
      在这里插入图片描述
    • 理所当然地,也大于等于非极大匹配的边集的边的数目。所以,我们有:所有的匹配对应的边集中边的数目总是小于等于所有的点覆盖对应的点集中点的数目,匹配的边集的边数是点覆盖的点集的点数的下界。更紧地,极大匹配的边集的边数是最小点覆盖的点集的点数的下界。

    近似算法

    找到图G中的一个极大匹配,输出极大匹配的点集。

    approximate factor(近似因子)

    近似比为2。 也就是说,该近似算法所得出的解是个可行解,而且这个可行解的成本一定在这个问题的最优解的成本的2倍之内,也就是我们要证极大匹配的点集(极大匹配边的左右端点),一定在最小基数点覆盖的点集的2倍内。

    证明

    • 如果是极大匹配的点集,那么一定是覆盖了所有边的至少一个端点,否则的话,可以再加一条没有被覆盖的边进入匹配中成为更大的匹配。我们现在让M作为极大匹配所选择的边集。
    • 之前我们已推出 |M|≤OPT,即所有的匹配对应的边集中边的数目总是小于等于所有的点覆盖对应的点集中点的数目,最大的匹配中边的数目≤最小点覆盖中点的数目。Kőnig’s theorem: 在二分图中,最大的匹配的边集中边的数目等于最小点覆盖的点集中点的数目)
    • 我们观察得,这种算法选择的覆盖,由于匹配的边为|M|,每条边左右两个端点,那么对应的覆盖点数为2|M|,因为|M|≤OPT,所以2|M|≤2·OPT,即依靠下界方案得到的最大的匹配的点集(匹配边的左右端点)≤最小点覆盖的点集的2倍/最优解的2倍,最大的匹配的点集/最小点覆盖的点集≤2。
    展开全文
  • 问题描述:就是在图中找最小的点集,使得覆盖所有边。 和独立集等价:独立集问题:在图中找最大的点集,使得点集内的所有点互不相连。 引理:顶点覆盖集和独立集互补。 ...上面这个引理使得这两个问题可以相互规约...

    问题描述:就是在图中找最小的点集,使得覆盖所有边。

    和独立集等价:独立集问题:在图中找最大的点集,使得点集内的所有点互不相连。

     

    引理:顶点覆盖集和独立集互补。

     

    上面这个引理使得这两个问题可以相互规约,从而这两个问题等价。

     

    等价问题:给定图G和数k, 问G包含大小至少为k的独立集吗?

    为什么等价:如果我们能在多项式时间内给出这个问题的答案,那么我们可以通过二分查找得到最大独立集的size为K。一个点如果是最大独立集中的点,等价于除去这个点后得到的图G'含有一个K-1大小的独立集。那么我们每次选取一个顶点v,然后再问一下G'是否有K-1的独立集,如果回答为yes,那么我们把v加入我们的答案中,如果回答为no, 我们把v的邻居加入答案中(因为如果v不在答案中,v的邻居也不在答案中,那么v和邻居之间的边将不会被覆盖)。所以,如果上述提问的解法是多项式的,那么最大独立集问题也是多项式的。

    转载于:https://www.cnblogs.com/huangshiyu13/p/7044196.html

    展开全文
  • Maximum Clique

    2017-11-12 12:20:03
    Maximum clique is the clique that has maximum number of vertex. Input Input contains multiple tests. For each test: The first line has one integer n, the number of vertex. (1 ) The following n ...
  • <div><p>Implements vertex buffer caching by means of a LRU (least recently used) cache. <p>The cache uses a std::list (linked list) of entries for fast insertion and removal, as well as a std::...
  • at aerys.minko.render.geometry.stream::VertexStream/getMinMaxBetween():218 at aerys.minko.render.geometry::Geometry/updateBoundingVolumes():850 at aerys.minko.render.geometry::Geometry/initialize()...
  • maximum flow

    2016-04-18 22:31:05
    mincut problem: an edge-weighted digraph, source vertex s, and target vertex t. a st-cut is a partition of the vertices into two disjoint sets, with s in one set A and t in the other set B. 他的容量...

    mincut problem: an edge-weighted digraph, source vertex s, and target vertex t.

    a st-cut is a partition of the vertices into two disjoint sets, with s in one set A and t in the other set B.

    他的容量就是从A到B的边的容量之和,而不计算从B到A的边。

    最小st-cut问题: 找一个cut,使得cut的容量最小。

    最大流问题: st-flow容量, 边的流 <= 边的容量。除了s和t,inflow = outflow。 流的值等于在t的inflow。需要找到一个值最大的flow。

    在augmenting paths增加flow。终止条件是: full forward edge 或者 empty backward edge.

    FFA:

    start with 0 flow

    while there exists an augmenting path:

          find an augmenting path

          compute bottleneck capacity

          increase flow on that path by bottleneck capacity.


    the net flow across a cut (A, B) is the sum of the flows on its edges from A to B minus the sum of the flows on its edges from B to A.

    Flow-value lemma: let f be any flow and let (A, B) be any cut. Then, the net flow across (A, B) equals the value of f.

    value of flow f = net flow across cut (A, B) <= capacity of cut (A, B)


    Augmenting path theorem: 如果没有增强路径,一个流是最大流

    Maxflow-mincut theorem: value of the maxflow = capacity of mincut

    对于任何一个流来说下面的3个条件是对等的

    i, 有一个cut的容量 = 流f的值

    ii, f是最大流

    iii, 对于f来说没有增强路径。

    i -> ii  ,  the value of any flow f' <= capacity of cut (A, B) = value of f, 所以f是最大流

    ii -> iii,     prove contrapositive

    iii -> i,      let (A, B) be a cut where A is the set of vertices connected to s by an undirected path with no full forward or empty backward edges. s is in A; since no augmenting path, t is in B. capacity of cut = net flow across cut (because forward edges full; backward edges empty) = value of flow f.


    展开全文
  • <p>Minimum weight vertex cover for hypergraphs has a k-approximation using the layering technique, where k is the maximum hyperedge size. See Vazirani, "Approximation Algorithms". <p>Richard ...
  • <div><p>I have code like ...t count because maximum execution time exceeded. <p>Graph is the same in both cases, so result has to be same too.</p><p>该提问来源于开源项目:graphp/graph</p></div>
  • Maximum Flow

    2014-01-12 18:43:45
    1. Definitions: ... -- Input : An edge-weighted digraph (edge capacity) , source vertex s, and target vertex t.  -- st-cut : A partition of the vertices into two disjoint sets, with s in on...

    1.  Definitions:  

        --  Input : An edge-weighted digraph (edge capacity) , source vertex s, and target vertex t.

        --  st-cut : A partition of the vertices into two disjoint sets, with s in one set A and t in the other set B.

        --  capacity of the cut (A, B) : The sum of the capacities of the edges from A to B. 

        --  Minimum st-cut (mincut) problem: Find a cut of minimum capacity.



     

    2.  Maxflow problem :

        --  Input: An edge-weighted (capacity) digraph , source vertex s, and target vertex t.

        --  An st-flow (flow) is an assignment of values to the edges such that:

            -  Capacity constraint: 0 ≤ edge's flow ≤ edge's capacity.

            -  Local equilibrium: inflow = outflow at every vertex (except s and t).

        --  The value of a flow is the inflow at t.( we assume no edge points to s or from t. )

        --  Maximum st-flow (maxflow) problem: Find a flow of maximum value.



     

    3.  Remarkable fact: Mincut problem and Maxflow problem are dual!

     

    4.  Ford-Fulkerson algorithm

        --  Initialization: Start with 0 flow.

        --  Find an augmenting path : undirected path from s to t such that:

            --  Can increase flow on forward edges (not full).

            --  Can decrease flow on backward edge (not empty).

        --  Increase flow along augmenting paths

        --  Termination: No augmenting path : All paths from s to t are blocked by either a

            --  Full forward edge.

            --  Empty backward edge.


     

     

    5.  Relationship between flows and cuts:

        --  The net flow across a cut (A, B) is the sum of the flows on its edges from A to B minus the sum of the flows on its edges from from B to A.

        --  Flow-value lemma. Let f be any flow and let (A, B) be any cut. Then, the net flow across (A, B) equals the value of f.

            --  Pf. By induction on the size of B.

                -  Base case: B = { t }.

                -  Induction step: remains true by local equilibrium when moving any vertex from A to B.

        --  Weak duality: Let f be any flow and let (A, B) be any cut. Then, the value of the flow ≤ the capacity of the cut.

            --  Pf. Value of flow f = net flow across cut (A, B) ≤ capacity of cut (A, B).



     

    6.  Maxflow-mincut theorem

        --  Augmenting path theorem: A flow f is a maxflow iff no augmenting paths.

        --  Maxflow-mincut theorem. Value of the maxflow = capacity of mincut.

        --  Pf. The following three conditions are equivalent for any flow f :

            i. There exists a cut whose capacity equals the value of the flow f.

            ii. f is a maxflow.

            iii. There is no augmenting path with respect to f.

            --  [ i ⇒ ii ]

                -  Suppose that (A, B) is a cut with capacity equal to the value of f.

                -  Then, the value of any flow f ' ≤ capacity of (A, B) = value of f.

                -  Thus, f is a maxflow.

            --  [ ii ⇒ iii ] We prove contrapositive: ~iii ⇒ ~ii.

                -  Suppose that there is an augmenting path with respect to f.

                -  Can improve flow f by sending flow along this path.

                -  Thus, f is not a maxflow.

            --  [ iii ⇒ i ]

                -  Suppose that there is no augmenting path with respect to f.

                -  Let (A, B) be a cut where A is the set of vertices connected to s by an undirected path with no full forward or empty backward edges.

                -  By definition, s is in A; since no augmenting path, t is in B.

                -  Capacity of cut = net flow across cut = value of flow f.

     

    7.  Computing a mincut from a maxflow:

        --  By augmenting path theorem, no augmenting paths with respect to f.

        --  Compute A = set of vertices connected to s by an undirected path with no full forward or empty backward edges.



     

    8.  Does FF always terminate?

        yes, provided edge capacities are integers (or augmenting paths are chosen carefully)

     

    9.  Ford-Fulkerson algorithm with integer capacities :

        --  Important special case: Edge capacities are integers between 1 and U.

        --  Invariant: The flow is integer-valued throughout Ford-Fulkerson.

            -- Pf. [by induction]

                -  Bottleneck capacity is an integer.

                - Flow on an edge increases/decreases by bottleneck capacity.

        --  Proposition. Number of augmentations ≤ the value of the maxflow.

            --  Pf. Each augmentation increases the value by at least 1.

        --  Integrality theorem. There exists an integer-valued maxflow.

            --  Pf. Ford-Fulkerson terminates and maxflow that it finds is integer-valued.

        --  Bad news : Even when edge capacities are integers, number of augmenting paths could be equal to the value of the maxflow.

        --  Good news : This case is easily avoided. [use shortest/fattest path]



     

    10.  FF performance depends on choice of augmenting paths :



     

    11.  Implementation Considerations of FF:

        --  Flow edge data type: Associate flow fe and capacity ce with edge e = v→w.

        --  Flow network data type: Need to process edge e = v→w in either direction: Include e in both v and w's adjacency lists.

        --  Residual capacity:

            -  Forward edge: residual capacity = ce - fe.

            -  Backward edge: residual capacity = fe.

        --  Augment flow.

            -  Forward edge: add Δ.

            -  Backward edge: subtract Δ.

        --  Residual network : Augmenting path in original network is equivalent to directed path in residual network.



     

    12.  Flow edge: Java implementation:

    public class FlowEdge
    {
        private final int v, w; // from v to w
        private final double capacity; // capacity
        private double flow; // flow
    
        public FlowEdge(int v, int w, double capacity)
        {
            this.v = v;
            this.w = w;
            this.capacity = capacity;
        }
    
        public int from() { return v; }
        public int to() { return w; }
        public double capacity() { return capacity; }
        public double flow() { return flow; }
        public int other(int vertex)
        {
            if (vertex == v) return w;
            else if (vertex == w) return v;
            else throw new RuntimeException("Illegal endpoint");
        }
    
        public double residualCapacityTo(int vertex)
        {
            if (vertex == v) return flow; // from w to v , backward edge
            else if (vertex == w) return capacity - flow; // from v to w, forward edge
            else throw new IllegalArgumentException();
        }
    
        public void addResidualFlowTo(int vertex, double delta)
        {
            if (vertex == v) flow -= delta; //backward edge
            else if (vertex == w) flow += delta; //forward edge
            else throw new IllegalArgumentException();
        }
    }

     

    13.  Flow network: Java implementation :

    public class FlowNetwork
    {
        private final int V;
        private Bag<FlowEdge>[] adj;
        public FlowNetwork(int V)
        {
            this.V = V;
            adj = (Bag<FlowEdge>[]) new Bag[V];
            for (int v = 0; v < V; v++)
                adj[v] = new Bag<FlowEdge>();
        }
    
        public void addEdge(FlowEdge e)
        {
            int v = e.from();
            int w = e.to();
            adj[v].add(e);
            adj[w].add(e);
        }
    
        public Iterable<FlowEdge> adj(int v)
        { return adj[v]; }
    }

     

    14.  Ford-Fulkerson: Java implementation :

    public class FordFulkerson
    {
        private boolean[] marked; // true if s->v path in residual network
        private FlowEdge[] edgeTo; // last edge on s->v path
        private double value; // value of flow
        
        public FordFulkerson(FlowNetwork G, int s, int t)
        {
            value = 0.0;
            while (hasAugmentingPath(G, s, t))
            {
                double bottle = Double.POSITIVE_INFINITY;
                for (int v = t; v != s; v = edgeTo[v].other(v))
                    bottle = Math.min(bottle, edgeTo[v].residualCapacityTo(v));
                for (int v = t; v != s; v = edgeTo[v].other(v))
                    edgeTo[v].addResidualFlowTo(v, bottle);
                value += bottle;
            }
        }
    
        public double value()
        { return value; }
    
        public boolean inCut(int v)
        { return marked[v]; }
    
        private boolean hasAugmentingPath(FlowNetwork G, int s, int t)
        {
            edgeTo = new FlowEdge[G.V()];
            marked = new boolean[G.V()];
            Queue<Integer> queue = new Queue<Integer>();
            queue.enqueue(s);
            marked[s] = true;
            while (!queue.isEmpty())
            {
                int v = queue.dequeue();
                for (FlowEdge e : G.adj(v))
                {
                    int w = e.other(v);
                    if (e.residualCapacityTo(w) > 0 && !marked[w])
                    {
                        edgeTo[w] = e;
                        marked[w] = true;
                        queue.enqueue(w);
                    }
                }
            }
            return marked[t];
        }
    }

     

    15.  Maxflow application on bipartite matching :

        --  Problem definition: (Given a bipartite graph, find a perfect matching.)

            -  N students apply for N jobs.

            -  Is there a way to match all students to jobs?

        --  Network flow formulation of bipartite matching :

            -  Create s, t, one vertex for each student, and one vertex for each job.

            -  Add edge from s to each student (capacity 1).

            -  Add edge from each job to t (capacity 1).

            -  Add edge from student to each job offered (infinite capacity).



     

        --  When no perfect matching, mincut explains why :

            Consider mincut (A, B).

            -  Let S = students on s side of cut.

            -  Let T = companies on s side of cut.

            -  Fact: | S | > | T |; students in S can be matched only to companies in T.



     

    16.  Maxflow application on Baseball elimination problem :

        --  Problem definition: Which teams have a chance of finishing the season with the most wins?



     

        --  Observation. Answer depends not only on how many games already won and left to play, but on whom they're against.

        --  maxflow formulation : Remaining games flow from s to t.



     

        --   Team 4 not eliminated iff all edges pointing from s are full in maxflow.

     

    展开全文
  • Maximum Clique+最大团

    2018-05-24 19:11:44
    Given a graph G(V, E), a clique is a sub-graph g(v, e), so that for all vertex pairs v1, v2 in v, there exists an edge (v1, v2) in e... Maximum clique is the clique that has maximum number of vertex. ...
  • Problem Description Given a graph G(V, E), a clique is a sub-graph g(v, e), so that for all ... Maximum clique is the clique that has maximum number of vertex. Input Input contains multiple te
  • Maximum White Subtree

    2020-03-26 15:15:55
    You are given a tree consisting of n vertices. A tree is a connected undirected graph with n−1 ... Each vertex v of this tree has a color assigned to it (av=1 if the vertex v is white and 0 if the ...
  • hdu1530 Maximum Clique

    2016-02-14 16:18:48
    Maximum Clique Problem Description ...Given a graph G(V, E), a clique is a sub-graph g(v, e), so that for all vertex pairs v1, v2 in v, there exists an edge (v1, v2) in e. Maximum clique is the c
  • The maximum balanced biclique problem (MBBP) is an important extension of the maximum clique problem (MCP), which has wide industrial applications. In this paper, we propose a new local search ...
  • F. Maximum White Subtree

    2021-03-29 20:26:16
    Maximum White Subtree time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given a tree consisting of n vertices. A tree is a connected ...
  • ).all().then or .map ends with maximum call stack error. Vertex 'Foo' is 143.000 records. With .limit(121398 +/-) working fine. How can I avoid this limit?</p><p>该提问来源于开源项目ÿ...
  • <div><p>Large input files (filesize / vertex count / properties) load slowly over the web, so it would be useful to have a "lite" or "preview" version that meets a 2 megabyte ...
  • HDU1530 Maximum Clique(最大团) Description Given a graph G(V, E), a clique is a sub-graph g(v, e), so that for all ... Maximum clique is the clique that has maximum number of vertex. Input Input contai
  • <p>Instead of defining the normal as the sum of incident face normals, it is computed as the normal that minimizes the maximum distance to the face normals. The default method is changed to be a sine-...
  • Maximum Clique-最大团dfs

    2014-05-01 16:00:54
    Maximum Clique 问题来源:hdu-1530 ...Given a graph G(V, E), a clique is a sub-graph g(v, e), so that for all vertex pairs v1, v2 in v, there exists an edge (v1, v2) in e. Maximum cliq
  • Given a graph G(V, E), a clique is a sub-graph g(v, e), so that for all vertex pairs v1, v2 in v, there exists an edge (v1, v2) in e. Maximum clique is the clique that has maximum number of vertex.
  • outputstandard output You are given a tree consisting of n vertices. A tree is a connected undirected graph with n−1 ... Each vertex v of this tree has a color assigned to it (av=1 if the vertex v ...
  • Maximum Clique(HDU-1530)

    2019-01-23 16:01:03
    Given a graph G(V, E), a clique is a sub-graph g(v, e), so that for all vertex pairs v1, v2 in v, there exists an edge (v1, v2) in e. Maximum clique is the clique that has maximu...
  • The vertex numbered with 1 corresponds to a mine from where some precious minerals are extracted. The vertex numbered with N corresponds to a minerals processing factory. Each edge has an associated ...
  • Maximum White Subtree time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given a tree consisting of n vertices. A tree is a connected ...
  • Maximum FPS: Three Tips for Faster Code

    千次阅读 2013-12-31 13:03:36
    Welcome back to Maximum FPS! Last month I spent a long time discussing the issues involved with writing to vertex buffers in AGP memory. If you downloaded and looked at the sample code that accompanie

空空如也

空空如也

1 2 3 4 5 ... 14
收藏数 264
精华内容 105
关键字:

maximumvertex