Projects >> wala-mirror >>7948f3b9aeae387218df2ef609e2f1b1e77c833b

Chunk
Conflicting content
import org.junit.Test;

<<<<<<< HEAD
import com.ibm.wala.util.collections.HashMapFactory;
import com.ibm.wala.util.collections.Pair;
=======
>>>>>>> c1a923d0ba7be6dec0abfd1a3b72e973302b6dd0
import com.ibm.wala.util.graph.Graph;
import com.ibm.wala.util.graph.NumberedGraph;
import com.ibm.wala.util.graph.impl.DelegatingNumberedGraph;
Solution content
import org.junit.Test;

import com.ibm.wala.util.collections.HashMapFactory;
import com.ibm.wala.util.collections.Pair;
import com.ibm.wala.util.graph.Graph;
import com.ibm.wala.util.graph.NumberedGraph;
import com.ibm.wala.util.graph.impl.DelegatingNumberedGraph;
File
WelshPowellTest.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
            new Integer[]{6, 3, 1, 4},
            new Integer[]{7, 1, 2, 4},
            new Integer[]{8, 1, 2, 3}});
<<<<<<< HEAD
      Pair, Integer>,Integer> colors = new WelshPowell>().color(G);
=======
      ColoredVertices colors = new WelshPowell().color(G);
>>>>>>> c1a923d0ba7be6dec0abfd1a3b72e973302b6dd0
      System.err.println(colors);
      assertColoring(G, colors.getColors());
      Assert.assertTrue(colors.getNumColors() <= 4);
Solution content
            new Integer[]{6, 3, 1, 4},
            new Integer[]{7, 1, 2, 4},
            new Integer[]{8, 1, 2, 3}});
      ColoredVertices> colors = new WelshPowell>().color(G);
      System.err.println(colors.getColors());
      assertColoring(G, colors.getColors());
      Assert.assertTrue(colors.getNumColors() <= 4);
File
WelshPowellTest.java
Developer's decision
Manual
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
           new String[]{"star3", "poly3", "star1", "star5"},
           new String[]{"star4", "poly4", "star1", "star2"},
           new String[]{"star5", "poly5", "star2", "star3"}});
<<<<<<< HEAD
      Pair, Integer>,Integer> colors = new WelshPowell>().color(G);
=======
      ColoredVertices colors = new WelshPowell().color(G);
>>>>>>> c1a923d0ba7be6dec0abfd1a3b72e973302b6dd0
      System.err.println(colors);
      assertColoring(G, colors.getColors());
      Assert.assertTrue(colors.getNumColors() == 3);       
Solution content
           new String[]{"star3", "poly3", "star1", "star5"},
           new String[]{"star4", "poly4", "star1", "star2"},
           new String[]{"star5", "poly5", "star2", "star3"}});
      ColoredVertices> colors = new WelshPowell>().color(G);
      System.err.println(colors.getColors());
      assertColoring(G, colors.getColors());
      Assert.assertTrue(colors.getNumColors() == 3);       
File
WelshPowellTest.java
Developer's decision
Manual
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
import java.util.TreeSet;

import com.ibm.wala.util.collections.HashMapFactory;
<<<<<<< HEAD
import com.ibm.wala.util.collections.Pair;
import com.ibm.wala.util.graph.INodeWithNumber;
import com.ibm.wala.util.graph.NumberedGraph;
=======
import com.ibm.wala.util.graph.Graph;
>>>>>>> c1a923d0ba7be6dec0abfd1a3b72e973302b6dd0

public class WelshPowell {
Solution content
import java.util.TreeSet;

import com.ibm.wala.util.collections.HashMapFactory;
import com.ibm.wala.util.graph.INodeWithNumber;
import com.ibm.wala.util.graph.NumberedGraph;

public class WelshPowell {
File
WelshPowell.java
Developer's decision
Combination
Kind of conflict
Import
Chunk
Conflicting content
public class WelshPowell {

<<<<<<< HEAD
  public static  Comparator defaultComparator(final NumberedGraph G) {
=======
  public static class ColoredVertices {
    private final boolean fullColoring;
    private final Map colors;
    private final int numColors;
    
    public boolean isFullColoring() {
      return fullColoring;
    }

    public Map getColors() {
      return colors;
    }

    public int getNumColors() {
      return numColors;
    }

    public ColoredVertices(boolean fullColoring, Map colors, int numColors) {
      this.fullColoring = fullColoring;
      this.colors = colors;
      this.numColors = numColors;
    }

  }

  public static  Comparator defaultComparator(final Graph G) {
>>>>>>> c1a923d0ba7be6dec0abfd1a3b72e973302b6dd0
    return new Comparator() {

      @Override
Solution content
public class WelshPowell {

  public static class ColoredVertices {
    private final boolean fullColoring;
    private final Map colors;
    private final int numColors;
    
    public boolean isFullColoring() {
      return fullColoring;
    }

    public Map getColors() {
      return colors;
    }

    public int getNumColors() {
      return numColors;
    }

    public ColoredVertices(boolean fullColoring, NumberedGraph G, int colors[], int numColors) {
      this(fullColoring, makeMap(G, colors), numColors);
    }

    private static  Map makeMap(NumberedGraph G, int[] colors) {
      Map colorMap = HashMapFactory.make();
      for(int i = 0; i < colors.length; i++) {
        colorMap.put(G.getNode(i), colors[i]);
      }
      return colorMap;
    }
    
    public ColoredVertices(boolean fullColoring, Map colors, int numColors) {
      this.fullColoring = fullColoring;
      this.colors = colors;
      this.numColors = numColors;
    }

  }

  public static  Comparator defaultComparator(final NumberedGraph G) {
    return new Comparator() {

      @Override
File
WelshPowell.java
Developer's decision
Manual
Kind of conflict
Class declaration
Method signature
Chunk
Conflicting content
      }
    };
  }
<<<<<<< HEAD
  
  public Pair, Integer>  color(final NumberedGraph G) {
    return color(G, defaultComparator(G));
  }
  
  public Pair, Integer>  color(final NumberedGraph G, Comparator order) {
    int[] colors = new int[ G.getNumberOfNodes() ];
    for(int i = 0; i < colors.length; i++) {
      colors[i] = -1;
    }

    SortedSet vertices = new TreeSet(order);

    for(T n : G) {
=======

  public ColoredVertices color(final Graph G) {
    return color(G, defaultComparator(G), Integer.MAX_VALUE);
  }
  
  public ColoredVertices color(final Graph G, int maxColors) {
    return color(G, defaultComparator(G), maxColors);
  }

  public ColoredVertices color(final Graph G, Comparator order, int maxColors) {
    Map colors = HashMapFactory.make();

    SortedSet vertices = new TreeSet(order);

    for (T n : G) {
>>>>>>> c1a923d0ba7be6dec0abfd1a3b72e973302b6dd0
      vertices.add(n);
    }
Solution content
      }
    };
  }
  
  public ColoredVertices color(final NumberedGraph G) {
    return color(G, defaultComparator(G), Integer.MAX_VALUE);
  }
  
  public ColoredVertices color(final NumberedGraph G, int maxColors) {
    return color(G, defaultComparator(G), maxColors);
  }

  public ColoredVertices color(final NumberedGraph G, Comparator order, int maxColors) {
    int[] colors = new int[ G.getMaxNumber() + 1];

    SortedSet vertices = new TreeSet(order);

    for (T n : G) {
      colors[n.getGraphNodeId()] = -1;
      vertices.add(n);
    }
File
WelshPowell.java
Developer's decision
Manual
Kind of conflict
For statement
Method declaration
Method invocation
Method signature
Variable
Chunk
Conflicting content
    }

    int currentColor = 0;
<<<<<<< HEAD
    int colored = 0;

    for(T n : vertices) {
      int id = n.getGraphNodeId();
      if (colors[id] == -1) {
        colors[id] = currentColor;
        colored++;

        for(T m : vertices) {
          if (colors[m.getGraphNodeId()] == -1) {
            color_me: {
              for(Iterator ps = G.getPredNodes(m); ps.hasNext(); ) {
                T p = ps.next();
                if (colors[ p.getGraphNodeId() ] == currentColor) {
                  break color_me;
                }
              }
  
              for(Iterator ss = G.getSuccNodes(m); ss.hasNext(); ) {
                T s = ss.next();
                if (colors[s.getGraphNodeId()] == currentColor) {
                  break color_me;
                }
=======
    for (T n : vertices) {
      if (!colors.containsKey(n)) {
        colors.put(n, currentColor);

        for (T m : vertices) {
          if (!colors.containsKey(m)) {
            color_me: {
            for (Iterator ps = G.getPredNodes(m); ps.hasNext();) {
              T p = ps.next();
              if (colors.containsKey(p) && colors.get(p) == currentColor) {
                break color_me;
>>>>>>> c1a923d0ba7be6dec0abfd1a3b72e973302b6dd0
              }
  
              colors[m.getGraphNodeId()] = currentColor;
Solution content
    }

    int currentColor = 0;
    int colored = 0;

    for(T n : vertices) {
      int id = n.getGraphNodeId();
      if (colors[id] == -1) {
        colors[id] = currentColor;
        colored++;

        for(T m : vertices) {
          if (colors[m.getGraphNodeId()] == -1) {
            color_me: {
              for(Iterator ps = G.getPredNodes(m); ps.hasNext(); ) {
                T p = ps.next();
                if (colors[ p.getGraphNodeId() ] == currentColor) {
                  break color_me;
                }
              }
  
              for(Iterator ss = G.getSuccNodes(m); ss.hasNext(); ) {
                T s = ss.next();
                if (colors[s.getGraphNodeId()] == currentColor) {
                  break color_me;
                }
              }
  
              colors[m.getGraphNodeId()] = currentColor;
File
WelshPowell.java
Developer's decision
Version 1
Kind of conflict
Array access
Break statement
For statement
If statement
Method invocation
Variable
Chunk
Conflicting content
          }
          }
        }
<<<<<<< HEAD

        currentColor++;
      }
    }
    assert colored == G.getNumberOfNodes();

    Map colorMap = HashMapFactory.make();
    for(int i = 0; i < colors.length; i++) {
      colorMap.put(G.getNode(i), colors[i]);
    }
    return Pair.make(colorMap, currentColor);
=======
        if (currentColor == maxColors - 1) {
          return new ColoredVertices(false, colors, currentColor);
        }
        currentColor++;
      }
    }

    assert colors.size() == G.getNumberOfNodes();
    return new ColoredVertices(true, colors, currentColor);
>>>>>>> c1a923d0ba7be6dec0abfd1a3b72e973302b6dd0
  }

}
Solution content
          }
        }

        currentColor++;

        if (currentColor == maxColors - 1) {
          return new ColoredVertices(false, G, colors, currentColor);
        }
      }
    }
    
    assert colored == G.getNumberOfNodes();

    return new ColoredVertices(true, G, colors, currentColor);
  }

}
File
WelshPowell.java
Developer's decision
Manual
Kind of conflict
Assert statement
For statement
If statement
Method invocation
Return statement
Variable