Skip to content

Commit

Permalink
New Graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
djayfresh committed Sep 5, 2014
1 parent 5fbaa50 commit 262ce8d
Show file tree
Hide file tree
Showing 60 changed files with 2,084 additions and 1,519 deletions.
22 changes: 22 additions & 0 deletions Workspace/.metadata/.log
Original file line number Diff line number Diff line change
Expand Up @@ -1397,3 +1397,25 @@ user global configuration and to define the default location to store repositori
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
!SESSION 2014-09-04 10:39:49.877 -----------------------------------------------
eclipse.buildId=4.4.0.I20140606-1215
java.version=1.8.0_05
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -product org.eclipse.epp.package.standard.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.standard.product

!ENTRY org.eclipse.egit.ui 2 0 2014-09-04 10:40:10.481
!MESSAGE Warning: EGit couldn't detect the installation path "gitPrefix" of native Git. Hence EGit can't respect system level
Git settings which might be configured in ${gitPrefix}/etc/gitconfig under the native Git installation directory.
The most important of these settings is core.autocrlf. Git for Windows by default sets this parameter to true in
this system level configuration. The Git installation location can be configured on the
Team > Git > Configuration preference page's 'System Settings' tab.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.

!ENTRY org.eclipse.egit.ui 2 0 2014-09-04 10:40:10.486
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:\Users\Doug'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/Fib/src/com/fresh/fib/Fib.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.fresh.fib.Fib"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Fib"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<launchHistory>
<launchGroup id="org.eclipse.debug.ui.launchGroup.debug">
<mruHistory>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;Fib&quot;/&gt;&#13;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;QueTesting&quot;/&gt;&#13;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;HeapClassTest&quot;/&gt;&#13;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;Driver&quot;/&gt;&#13;&#10;"/>
Expand All @@ -21,6 +22,7 @@
</launchGroup>
<launchGroup id="org.eclipse.debug.ui.launchGroup.run">
<mruHistory>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;Fib&quot;/&gt;&#13;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;QueTesting&quot;/&gt;&#13;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;HeapClassTest&quot;/&gt;&#13;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;Driver&quot;/&gt;&#13;&#10;"/>
Expand Down
3,045 changes: 1,586 additions & 1,459 deletions Workspace/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi

Large diffs are not rendered by default.

Binary file modified Workspace/.metadata/.plugins/org.eclipse.jdt.core/1528163545.index
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
INDEX VERSION 1.127+D:\Dropbox\Dropbox\School\Semester12\Algo 2\Git\Algo2\Workspace\.metadata\.plugins\org.eclipse.jdt.core
4183445374.index
735681076.index
2394657268.index
2708055714.index
1528163545.index
3926188048.index
1893439535.index
3272298222.index
774558276.index
3167461448.index
1244022644.index
2943934462.index
2725327845.index
1893439535.index
3581737588.index
2725327845.index
2860809195.index
648820999.index
3224974857.index
3549880408.index
2010491873.index
2503134553.index
3829748403.index
1369127545.index
182735413.index
2573849602.index
2705315894.index
Binary file not shown.
Binary file modified Workspace/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Workspace/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Workspace/.metadata/.plugins/org.eclipse.jdt.ui/jdt-images/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<session version="1.0">
<refactoring clone="true" comment="Infer generic type arguments on &apos;Fib&apos;&#x0D;&#x0A;- Original project: &apos;Fib&apos;&#x0D;&#x0A;- Original elements:&#x0D;&#x0A; com.fresh.fib.Fib.java&#x0D;&#x0A;- Assume clone() returns an instance of the receiver type&#x0D;&#x0A;- Leave unconstrained type arguments raw" description="Infer generic type arguments" element1="/src&lt;com.fresh.fib{Fib.java" flags="6" id="org.eclipse.jdt.ui.infer.typearguments" leave="true" stamp="1409850395945" version="1.0"/>
</session>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1409850395945 Infer generic type arguments
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<session version="1.0">&#x0A;<refactoring comment="Rename field &apos;Mark&apos; in &apos;com.fresh.graph.GraphMatrix&apos; to &apos;mark&apos;&#x0D;&#x0A;- Original project: &apos;Graphs&apos;&#x0D;&#x0A;- Original element: &apos;com.fresh.graph.GraphMatrix.Mark&apos;&#x0D;&#x0A;- Renamed element: &apos;com.fresh.graph.GraphMatrix.mark&apos;&#x0D;&#x0A;- Update references to refactored element&#x0D;&#x0A;- Update textual occurrences in comments and strings" delegate="false" deprecate="false" description="Rename field &apos;Mark&apos;" flags="589826" getter="false" id="org.eclipse.jdt.ui.rename.field" input="/src&lt;com.fresh.graph{GraphMatrix.java[GraphMatrix^Mark" name="mark" references="true" setter="false" stamp="1409932353006" textual="false" version="1.0"/>&#x0A;<refactoring comment="Move 3 elements to &apos;Graphs/src/com.fresh.broken&apos;&#x0D;&#x0A;- Original project: &apos;Graphs&apos;&#x0D;&#x0A;- Destination element: &apos;Graphs/src/com.fresh.broken&apos;&#x0D;&#x0A;- Original elements:&#x0D;&#x0A; com.fresh.graph.MatrixGraph.java&#x0D;&#x0A; com.fresh.graph.ListGraph.java&#x0D;&#x0A; com.fresh.graph.Vertex.java&#x0D;&#x0A;- Update references to refactored element" description="Move compilation units" destination="/src&lt;com.fresh.broken" element1="/src&lt;com.fresh.graph{MatrixGraph.java" element2="/src&lt;com.fresh.graph{ListGraph.java" element3="/src&lt;com.fresh.graph{Vertex.java" files="0" flags="589830" folders="0" id="org.eclipse.jdt.ui.move" patterns="*" policy="org.eclipse.jdt.ui.moveResources" qualified="false" references="true" stamp="1409932553199" units="3" version="1.0"/>
</session>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1409932353006 Rename field 'Mark'
1409932553199 Move compilation units
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Cached timestamps
#Mon Aug 25 11:43:49 MDT 2014
#Thu Sep 04 09:29:13 MDT 2014
2 changes: 1 addition & 1 deletion Workspace/.metadata/version.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#Thu Sep 04 09:14:38 MDT 2014
#Thu Sep 04 10:39:53 MDT 2014
org.eclipse.core.runtime=2
org.eclipse.platform=4.4.0.v20140606-1215
6 changes: 6 additions & 0 deletions Workspace/Fib/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions Workspace/Fib/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Fib</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions Workspace/Fib/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
45 changes: 45 additions & 0 deletions Workspace/Fib/src/com/fresh/fib/Fib.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.fresh.fib;

import java.util.HashMap;

public class Fib
{
static HashMap<Long, Long> fiblist = new HashMap<Long,Long>();

public static void main(String[] args)
{
long time = System.nanoTime();
System.out.println(fib(25));
System.out.println("Fib time: " + (System.nanoTime() - time)/1000 + "ms");

time = System.nanoTime();
System.out.println(fib(50));
System.out.println("Fib time: " + (System.nanoTime() - time)/1000 + "ms");

time = System.nanoTime();
System.out.println(betterFib(50));
System.out.println("Fib time: " + (System.nanoTime() - time)/1000 + "ms");
}

static long fib(long n)
{
if(n < 2)
return n;
return fib(n-1) + fib(n-2);
}

static long betterFib(int n)
{
if(n < 2) return n;

long[] list = new long[n+1];
list[0] = 0;
list[1] = 1;

for(int i = 2; i <= n; i++)
{
list[i] = list[i-2] + list[i-1];
}
return list[n];
}
}
116 changes: 116 additions & 0 deletions Workspace/Graphs/src/com/fresh/broken/ListGraph.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package com.fresh.broken;

import java.lang.reflect.Array;
import java.util.ArrayList;

public class ListGraph
{
public static final int VISITED = 2;
//Vertex<T>[] verts;
ArrayList<Edge>[] list;
int[] marks;

@SuppressWarnings("unchecked")
public ListGraph(int n)
{
//verts = (Vertex<T>[]) Array.newInstance(verts.getClass(), n);
list = (ArrayList<Edge>[]) Array.newInstance(list.getClass(), n);
marks = new int[n];
}

public int first(int v)
{
return list[v].get(0).v2;
}

public int vCount()
{
return list.length;
}

public int neighborCount(int v)
{
return list[v].size();
}

public int next(int v, int lastNeighbor)
{
return list[v].get(lastNeighbor + 1).v2;
}

/**
*
* @param vertex
* @param neighbor
* @param weight - any weight non-Zero
* @throws Exception for a weight of Zero
*/
public void addEdge(int vertex, int neighbor, int weight) throws Exception
{
// add 0 throw exception
if(weight == 0)
{
throw new Exception("Weight of Zero");
}
list[vertex].add(new Edge(neighbor, weight));
}

public void removeEdge(int vertex, int neighbor)
{
list[vertex].remove(new Edge(neighbor,0));
}
/**
*
* @param vertex
* @param neighbor
* @return weight of edge or Zero if no weight found
*/
public int weight(int vertex, int neighbor)
{
return isEdge(vertex, neighbor)? list[vertex].get(list[vertex].indexOf(new Edge(neighbor, 0))).weight : 0;
}

public boolean isEdge(int vertex, int neighbor)
{
return list[vertex].contains(new Edge(neighbor, 0));
}

public void setMark(int vertex, int mark)
{
marks[vertex] = mark;
}

public int getMark(int vertex)
{
return marks[vertex];
}

public void clearMarks()
{
marks = new int[vCount()];
}

private class Edge implements Comparable<Edge>
{
public Integer v2;
public int weight;

public Edge(int v2, int weight)
{
this.v2 = v2;
this.weight = weight;
}

@Override
public int compareTo(ListGraph.Edge o)
{
return v2.compareTo(o.v2);
}

@Override
public boolean equals(Object object)
{
return ((ListGraph.Edge) object).v2 == v2;
}
}
}
53 changes: 53 additions & 0 deletions Workspace/Graphs/src/com/fresh/broken/MatrixGraph.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.fresh.broken;

import java.lang.reflect.Array;
import java.util.List;

import com.fresh.graph.ClassGraph;

public class MatrixGraph<T extends Vertex<E>, E extends Comparable<E>>
{
private ClassGraph graph;
private T[][] matrix;
@SuppressWarnings("unchecked")
public MatrixGraph(int n, Class<T> tClass)
{
graph = new ClassGraph(n);
matrix = (T[][]) Array.newInstance(tClass, n);
}

public int vCount()
{
return matrix.length;
}
public boolean add(T p1, T p2)
{
return false;
}

public boolean remove(T p1, T p2)
{
return false;
}

public List<T> retreive(T p1)
{
return null;
}

public int mark(T p1)
{
return 0;
}

public T first(T p1)
{
return null;
}

public T next(T p2, T p1)
{
return null;
}

}
11 changes: 11 additions & 0 deletions Workspace/Graphs/src/com/fresh/broken/Vertex.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.fresh.broken;

public class Vertex<T extends Comparable<T>>
{
public int mark;
public T data;
public Vertex(T data)
{
this.data = data;
}
}
Loading

0 comments on commit 262ce8d

Please sign in to comment.