diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e69de29
diff --git a/echoStream/.classpath b/echoStream/.classpath
new file mode 100644
index 0000000..fceb480
--- /dev/null
+++ b/echoStream/.classpath
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/echoStream/.project b/echoStream/.project
new file mode 100644
index 0000000..ad7f20e
--- /dev/null
+++ b/echoStream/.project
@@ -0,0 +1,17 @@
+
+
+ echoStream
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/echoStream/.settings/org.eclipse.core.resources.prefs b/echoStream/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..99f26c0
--- /dev/null
+++ b/echoStream/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/=UTF-8
diff --git a/echoStream/.settings/org.eclipse.jdt.core.prefs b/echoStream/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..ef0604b
--- /dev/null
+++ b/echoStream/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,14 @@
+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.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/echoStream/bin/GUI/Gui$1.class b/echoStream/bin/GUI/Gui$1.class
new file mode 100644
index 0000000..dd9f472
Binary files /dev/null and b/echoStream/bin/GUI/Gui$1.class differ
diff --git a/echoStream/bin/GUI/Gui$2.class b/echoStream/bin/GUI/Gui$2.class
new file mode 100644
index 0000000..0e6f2f7
Binary files /dev/null and b/echoStream/bin/GUI/Gui$2.class differ
diff --git a/echoStream/bin/GUI/Gui$3.class b/echoStream/bin/GUI/Gui$3.class
new file mode 100644
index 0000000..6c2223e
Binary files /dev/null and b/echoStream/bin/GUI/Gui$3.class differ
diff --git a/echoStream/bin/GUI/Gui.class b/echoStream/bin/GUI/Gui.class
new file mode 100644
index 0000000..0ca6a65
Binary files /dev/null and b/echoStream/bin/GUI/Gui.class differ
diff --git a/echoStream/bin/components/GlobalHolder.class b/echoStream/bin/components/GlobalHolder.class
new file mode 100644
index 0000000..7045558
Binary files /dev/null and b/echoStream/bin/components/GlobalHolder.class differ
diff --git a/echoStream/bin/components/Graph.class b/echoStream/bin/components/Graph.class
new file mode 100644
index 0000000..21ac649
Binary files /dev/null and b/echoStream/bin/components/Graph.class differ
diff --git a/echoStream/bin/components/IndexPriorityQueue$Element.class b/echoStream/bin/components/IndexPriorityQueue$Element.class
new file mode 100644
index 0000000..f894f3e
Binary files /dev/null and b/echoStream/bin/components/IndexPriorityQueue$Element.class differ
diff --git a/echoStream/bin/components/IndexPriorityQueue$IndexValue.class b/echoStream/bin/components/IndexPriorityQueue$IndexValue.class
new file mode 100644
index 0000000..701c702
Binary files /dev/null and b/echoStream/bin/components/IndexPriorityQueue$IndexValue.class differ
diff --git a/echoStream/bin/components/IndexPriorityQueue.class b/echoStream/bin/components/IndexPriorityQueue.class
new file mode 100644
index 0000000..83b3cc7
Binary files /dev/null and b/echoStream/bin/components/IndexPriorityQueue.class differ
diff --git a/echoStream/bin/components/Post$1.class b/echoStream/bin/components/Post$1.class
new file mode 100644
index 0000000..2bef005
Binary files /dev/null and b/echoStream/bin/components/Post$1.class differ
diff --git a/echoStream/bin/components/Post$2.class b/echoStream/bin/components/Post$2.class
new file mode 100644
index 0000000..539db92
Binary files /dev/null and b/echoStream/bin/components/Post$2.class differ
diff --git a/echoStream/bin/components/Post$3.class b/echoStream/bin/components/Post$3.class
new file mode 100644
index 0000000..0e18fe5
Binary files /dev/null and b/echoStream/bin/components/Post$3.class differ
diff --git a/echoStream/bin/components/Post.class b/echoStream/bin/components/Post.class
new file mode 100644
index 0000000..879abe8
Binary files /dev/null and b/echoStream/bin/components/Post.class differ
diff --git a/echoStream/bin/components/Tag$PopularityComparator.class b/echoStream/bin/components/Tag$PopularityComparator.class
new file mode 100644
index 0000000..34b8adb
Binary files /dev/null and b/echoStream/bin/components/Tag$PopularityComparator.class differ
diff --git a/echoStream/bin/components/Tag.class b/echoStream/bin/components/Tag.class
new file mode 100644
index 0000000..9a2ff63
Binary files /dev/null and b/echoStream/bin/components/Tag.class differ
diff --git a/echoStream/bin/interfaces/HasPopularity.class b/echoStream/bin/interfaces/HasPopularity.class
new file mode 100644
index 0000000..337b4ef
Binary files /dev/null and b/echoStream/bin/interfaces/HasPopularity.class differ
diff --git a/echoStream/bin/interfaces/HasPost.class b/echoStream/bin/interfaces/HasPost.class
new file mode 100644
index 0000000..f06997d
Binary files /dev/null and b/echoStream/bin/interfaces/HasPost.class differ
diff --git a/echoStream/bin/interfaces/HasTag.class b/echoStream/bin/interfaces/HasTag.class
new file mode 100644
index 0000000..a6c0fa9
Binary files /dev/null and b/echoStream/bin/interfaces/HasTag.class differ
diff --git a/echoStream/bin/phaseOne/Phase1.class b/echoStream/bin/phaseOne/Phase1.class
new file mode 100644
index 0000000..5b3424b
Binary files /dev/null and b/echoStream/bin/phaseOne/Phase1.class differ
diff --git a/echoStream/bin/utilities/CreateMedia.class b/echoStream/bin/utilities/CreateMedia.class
new file mode 100644
index 0000000..3ccecc6
Binary files /dev/null and b/echoStream/bin/utilities/CreateMedia.class differ
diff --git a/echoStream/bin/utilities/TagComparator.class b/echoStream/bin/utilities/TagComparator.class
new file mode 100644
index 0000000..d5782ef
Binary files /dev/null and b/echoStream/bin/utilities/TagComparator.class differ
diff --git a/echoStream/src/GUI/Gui.java b/echoStream/src/GUI/Gui.java
new file mode 100644
index 0000000..fac3f7a
--- /dev/null
+++ b/echoStream/src/GUI/Gui.java
@@ -0,0 +1,93 @@
+package GUI;
+import phaseOne.Phase1;
+
+import javax.swing.*;
+
+import components.Post;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+
+public class Gui extends JFrame {
+ static final long serialVersionUID = 6536891361170925993L;
+ private int currentPage = 1;
+ private final int postsPerPage = 20;
+ private ArrayList posts;
+ private JPanel postsPanel;
+ private JScrollPane scrollPane;
+
+ public Gui() {
+ setTitle("Social Media App");
+ setSize(600, 800);
+ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ setLayout(new BorderLayout());
+ Phase1 tempo = new Phase1();
+
+ posts = tempo.getRawTempoData();
+
+// posts = new ArrayList<>();
+//
+// for (int i = 1; i <= 50; i++) {
+// posts.add(new Post("Post " + i, "Caption for post " + i, "HashTag" + i));
+// }
+
+ postsPanel = new JPanel();
+ postsPanel.setLayout(new BoxLayout(postsPanel, BoxLayout.Y_AXIS));
+ scrollPane = new JScrollPane(postsPanel);
+
+ loadPosts();
+
+ JPanel buttonPanel = new JPanel();
+ JButton prevButton = new JButton("Previous");
+ JButton nextButton = new JButton("Next");
+ prevButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (currentPage > 1) {
+ currentPage--;
+ loadPosts();
+ }
+ }
+ });
+ nextButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (currentPage < (posts.size() / postsPerPage)) {
+ currentPage++;
+ loadPosts();
+ }
+ }
+ });
+ buttonPanel.add(prevButton);
+ buttonPanel.add(nextButton);
+
+ add(scrollPane, BorderLayout.CENTER);
+ add(buttonPanel, BorderLayout.SOUTH);
+ }
+
+ private void loadPosts() {
+ postsPanel.removeAll();
+ int start = (currentPage - 1) * postsPerPage;
+ int end = Math.min(start + postsPerPage, posts.size());
+ for (int i = start; i < end; i++) {
+ postsPanel.add(posts.get(i).getPostPanel());
+ }
+ postsPanel.revalidate();
+ postsPanel.repaint();
+ }
+
+
+
+
+ public static void main(String[] args) {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ new Gui().setVisible(true);
+ }
+ });
+ }
+
+
+}
\ No newline at end of file
diff --git a/echoStream/src/components/GlobalHolder.java b/echoStream/src/components/GlobalHolder.java
new file mode 100644
index 0000000..7c317cb
--- /dev/null
+++ b/echoStream/src/components/GlobalHolder.java
@@ -0,0 +1,40 @@
+package components;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class GlobalHolder {
+ private static GlobalHolder instance;
+ private Map sharedValues;
+
+ private GlobalHolder() {
+ sharedValues = new HashMap<>();
+ } // Private constructor
+
+ public static GlobalHolder getInstance() {
+ if (instance == null) {
+ instance = new GlobalHolder();
+ }
+ return instance;
+ }
+
+ public Float getSharedValue(String key) {
+ return sharedValues.get(key);
+ }
+
+ public void setSharedValue(String key, Float value) {
+ sharedValues.put(key, value);
+ }
+
+ public void removeSharedValue(String key) {
+ sharedValues.remove(key);
+ }
+
+ public boolean containsKey(String key) {
+ return sharedValues.containsKey(key);
+ }
+
+ public Map getAllSharedValues() {
+ return new HashMap<>(sharedValues);
+ }
+}
diff --git a/echoStream/src/components/Graph.java b/echoStream/src/components/Graph.java
new file mode 100644
index 0000000..fc5d3bd
--- /dev/null
+++ b/echoStream/src/components/Graph.java
@@ -0,0 +1,170 @@
+package components;
+
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.PriorityQueue;
+import java.util.TreeMap;
+
+import interfaces.HasPost;
+import interfaces.HasTag;
+import utilities.TagComparator;
+
+public class Graph {
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private Map> map = new TreeMap<>(new TagComparator());
+
+ // This function adds a new vertex to the graph
+ public void addVertex(T s) {
+ if (!map.containsKey(s)) {
+ map.put(s, new PriorityQueue<>((a1, a2) -> Float.compare(a1.getPriority(), a2.getPriority())));
+ } else {
+ System.out.println("Vertex already exists: " + s.getTitle());
+ }
+ }
+
+ // This function adds the edge between source and destination
+ public void addEdge(T source, A destination) {
+ if (!map.containsKey(source)) {
+ addVertex(source);
+ }
+ map.get(source).offer(destination); // Using offer to add elements to the priority queue
+ }
+
+
+
+
+
+ //just for testing
+ public void getKey(T source) {
+ PriorityQueue collection = map.get(source);
+ ArrayList list = new ArrayList<>(collection);
+ System.out.println(list.get(1).getPriority());
+ }
+
+
+ //setting TagPopularity Dynamically
+ @SuppressWarnings("unchecked")
+ public void setTagPopularity(T vertex, float newPopularity) {
+
+ if (!map.containsKey(vertex)) {
+ System.out.println("Vertex not found.");
+ return;
+ }
+
+ PriorityQueue edges = map.remove(vertex);
+
+ Tag tempoTag = new Tag(vertex.getTitle());
+ tempoTag.setPopularity(newPopularity);
+ GlobalHolder.getInstance().setSharedValue(tempoTag.getTitle(),newPopularity);
+
+
+
+
+ // Create a new vertex with updated priority
+
+
+
+ // Replace the old vertex in the map with the new one
+ map.put((T) tempoTag, edges);
+ }
+
+
+ //setting Post Priority Dynamically
+ public void setPriority(T source, String element, float newPriority) {
+ PriorityQueue collection = map.get(source);
+ if (collection == null) {
+ System.out.println("No such priority queue for the given source.");
+ return;
+ }
+
+ // Create a temporary priority queue to hold the updated elements
+ PriorityQueue updatedQueue = new PriorityQueue<>((a1, a2) -> Float.compare(a1.getPriority(), a2.getPriority()));
+ boolean found = false;
+
+ // Iterate through the original queue to find and update the element
+ for (A e : collection) {
+ if (e.getTitle().equals(element)) {
+
+ e.setPriority(newPriority);
+
+ found = true;
+ }
+ updatedQueue.add(e);
+ }
+
+ if (!found) {
+ System.out.println("Element not found in the priority queue.");
+ return;
+ }
+
+ // Replace the old priority queue with the updated one
+
+ map.put(source, updatedQueue);
+ }
+
+ // This function gives the count of vertices
+ public void getVertexCount() {
+ System.out.println("The graph has " + map.keySet().size() + " vertices.");
+ }
+
+ // This function gives the count of edges
+ public void getEdgesCount() {
+ int count = 0;
+ for (PriorityQueue neighbors : map.values()) {
+ count += neighbors.size();
+ }
+ System.out.println("The graph has " + count + " edges.");
+ }
+
+ // This function gives whether a vertex is present or not
+ public void hasVertex(T s) {
+ if (map.containsKey(s)) {
+ System.out.println("The graph contains " + s.getTitle() + " as a vertex.");
+ } else {
+ System.out.println("The graph does not contain " + s.getTitle() + " as a vertex.");
+ }
+ }
+
+ // This function gives whether an edge is present or not
+ public void hasEdge(T s, A d) {
+ if (map.containsKey(s)) {
+ PriorityQueue queue = map.get(s);
+ // Check if the destination exists in the queue
+ if (queue.contains(d)) {
+ System.out.println("The graph has an edge between " + s.getTitle() + " and " + d.getTitle() + ".");
+ } else {
+ System.out.println("The graph has no edge between " + s.getTitle() + " and " + d.getTitle() + ".");
+ }
+ } else {
+ System.out.println("The graph has no edge between " + s.getTitle() + " and " + d.getTitle() + ".");
+ }
+ }
+
+ // This function prints the neighbors of a vertex
+ public void neighbours(T s) {
+ if (!map.containsKey(s)) {
+ System.out.println("Vertex " + s.getTitle() + " not found.");
+ return;
+ }
+ System.out.print("The neighbors of " + s.getTitle() + " are: ");
+ for (A w : map.get(s)) {
+ System.out.print(w.getTitle() + " ");
+ }
+ System.out.println();
+ }
+
+ // Prints the adjacency list of each vertex
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ for (T v : map.keySet()) {
+ builder.append(v.getTitle()).append(": ");
+ for (A w : map.get(v)) {
+ builder.append(w.getTitle()).append(" <-> ");
+ }
+ builder.append("\n");
+ }
+ return builder.toString();
+ }
+}
diff --git a/echoStream/src/components/IndexPriorityQueue.java b/echoStream/src/components/IndexPriorityQueue.java
new file mode 100644
index 0000000..a1f47b4
--- /dev/null
+++ b/echoStream/src/components/IndexPriorityQueue.java
@@ -0,0 +1,109 @@
+package components;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Comparator;
+
+import java.util.PriorityQueue;
+
+
+public class IndexPriorityQueue {
+ private PriorityQueue queue;
+ private T[] data;
+ private int size;
+
+ private class Element {
+ int index;
+ T value;
+ Element(int index, T value) {
+ this.index = index;
+ this.value = value;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public IndexPriorityQueue(int capacity) {
+ this.queue = new PriorityQueue<>(Comparator.comparingInt(e -> e.index));
+ this.data = (T[]) new Object[capacity];
+ this.size = 0;
+ }
+
+ public void add(int index, T value) {
+ if (index >= data.length || index < 0) {
+ throw new IndexOutOfBoundsException("Index out of bounds");
+ }
+ // Update element and priority queue
+ data[index] = value;
+ queue.add(new Element(index, value));
+ size++;
+ }
+
+ public IndexValue poll() {
+ Element element = queue.poll();
+ if (element != null) {
+ T value = data[element.index];
+ data[element.index] = null;
+ size--;
+ return new IndexValue<>(element.index, value);
+ }
+ return null;
+ }
+
+ public IndexValue remove(int index) {
+ if (index >= data.length || index < 0) {
+ throw new IndexOutOfBoundsException("Index out of bounds");
+ }
+ // Remove element from priority queue and data array
+ Element toRemove = null;
+ for (Element e : queue) {
+ if (e.index == index) {
+ toRemove = e;
+ break;
+ }
+ }
+ if (toRemove != null) {
+ queue.remove(toRemove);
+ T value = data[index];
+ data[index] = null;
+ size--;
+ return new IndexValue<>(index, value);
+ }
+ return null;
+ }
+
+ public T get(int index) {
+ if (index >= data.length || index < 0) {
+ throw new IndexOutOfBoundsException("Index out of bounds");
+ }
+ return data[index];
+ }
+
+ public int size() {
+ return size;
+ }
+
+ public List getElements() {
+ List elements = new ArrayList<>();
+ for (Element e : queue) {
+ elements.add(e.value);
+ }
+ return elements;
+ }
+
+ public static class IndexValue {
+ public final int index;
+ public final T value;
+
+ public IndexValue(int index, T value) {
+ this.index = index;
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return "IndexValue{" +
+ "index=" + index +
+ ", value=" + value +
+ '}';
+ }
+ }
+}
diff --git a/echoStream/src/components/Post.java b/echoStream/src/components/Post.java
new file mode 100644
index 0000000..fa6af88
--- /dev/null
+++ b/echoStream/src/components/Post.java
@@ -0,0 +1,134 @@
+package components;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.Objects;
+
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import interfaces.HasPost;
+
+public class Post implements HasPost, Comparable {
+ private String title;
+ private String caption;
+ private String hashTag;
+ private int likes;
+ private int unlikes;
+ private int comments;
+ private float priority;
+ private ArrayList tagsGroup;
+
+ public Post(String title, String caption, String hashTag,float priority,ArrayList tagsGroup) {
+ this.title = title;
+ this.caption = caption;
+ this.hashTag = hashTag;
+ this.priority = priority;
+ this.likes = 0;
+ this.unlikes = 0;
+ this.comments = 0;
+ this.tagsGroup = tagsGroup;
+ }
+
+ @Override
+ public void setPriority(float newPriority) {
+ this.priority = newPriority;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Post post = (Post) o;
+ return Float.compare(post.priority, priority) == 0 &&
+ title.equals(post.title);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(title, priority);
+ }
+ public String getTitle() {
+ return this.title;
+ }
+
+ public String getCaption() {
+ return this.caption;
+ }
+
+ public String getHashTag() {
+ return this.hashTag;
+ }
+
+
+ public float getPriority() {
+ return this.priority;
+ }
+
+
+ //UI part
+ public JPanel getPostPanel() {
+ JPanel postPanel = new JPanel();
+ postPanel.setLayout(new BoxLayout(postPanel, BoxLayout.Y_AXIS));
+ postPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
+ postPanel.setPreferredSize(new Dimension(550, 100));
+
+ JLabel titleLabel = new JLabel(title);
+ JLabel captionLabel = new JLabel(caption);
+ JLabel hashTagLabel = new JLabel(hashTag);
+ JButton likeButton = new JButton("Like (" + likes + ")");
+ JButton unlikeButton = new JButton("Unlike (" + unlikes + ")");
+ JButton commentButton = new JButton("Comment (" + comments + ")");
+
+ likeButton.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ likes++;
+ likeButton.setText("Like (" + likes + ")");
+ }
+ });
+
+
+unlikeButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ unlikes++;
+ unlikeButton.setText("Unlike (" + unlikes + ")");
+
+ }
+ });
+
+ commentButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ comments++;
+ commentButton.setText("Comment (" + comments + ")");
+ }
+ });
+
+ postPanel.add(titleLabel);
+ postPanel.add(captionLabel);
+ postPanel.add(hashTagLabel);
+ postPanel.add(likeButton);
+ postPanel.add(unlikeButton);
+ postPanel.add(commentButton);
+
+ return postPanel;
+ }
+
+ @Override
+ public int compareTo(Post o) {
+ // TODO Auto-generated method stub
+ return Float.compare(o.priority, this.priority);
+ }
+
+
+
+
+}
diff --git a/echoStream/src/components/Tag.java b/echoStream/src/components/Tag.java
new file mode 100644
index 0000000..66e65c6
--- /dev/null
+++ b/echoStream/src/components/Tag.java
@@ -0,0 +1,54 @@
+package components;
+
+import java.util.*;
+
+import interfaces.HasTag;
+
+public class Tag implements HasTag {
+ public String title;
+ private float popularity;
+// private int tagId;
+
+ public Tag(String title) {
+ this.title = title;
+ this.popularity = 1f;
+
+ }
+
+ public String getTitle() {
+ return this.title;
+ }
+
+ public float getPopularity() {
+ return popularity;
+ }
+
+ public void setPopularity(float newPriority) {
+ this.popularity = newPriority;
+ System.out.println("hi");
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Tag tag = (Tag) o;
+ return Objects.equals(title, tag.title);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(title);
+ }
+
+
+ // Comparator for popularity
+ public static class PopularityComparator implements Comparator {
+ @Override
+ public int compare(Tag t1, Tag t2) {
+ return Float.compare(t1.getPopularity(), t2.getPopularity());
+ }
+ }
+
+
+}
diff --git a/echoStream/src/interfaces/HasPopularity.java b/echoStream/src/interfaces/HasPopularity.java
new file mode 100644
index 0000000..ffcfc8f
--- /dev/null
+++ b/echoStream/src/interfaces/HasPopularity.java
@@ -0,0 +1,7 @@
+package interfaces;
+
+public interface HasPopularity {
+ float getPriority(String tag);
+ void setPriority(String tag,float popularity);
+
+}
diff --git a/echoStream/src/interfaces/HasPost.java b/echoStream/src/interfaces/HasPost.java
new file mode 100644
index 0000000..fe08e71
--- /dev/null
+++ b/echoStream/src/interfaces/HasPost.java
@@ -0,0 +1,10 @@
+package interfaces;
+
+public interface HasPost {
+ String getTitle();
+ String getCaption();
+ String getHashTag();
+ float getPriority();
+ void setPriority(float newPriority);
+
+}
diff --git a/echoStream/src/interfaces/HasTag.java b/echoStream/src/interfaces/HasTag.java
new file mode 100644
index 0000000..3341c4e
--- /dev/null
+++ b/echoStream/src/interfaces/HasTag.java
@@ -0,0 +1,8 @@
+package interfaces;
+
+public interface HasTag {
+ String getTitle();
+ float getPopularity();
+ void setPopularity(float newPopularity);
+
+}
diff --git a/echoStream/src/phaseOne/Phase1.java b/echoStream/src/phaseOne/Phase1.java
new file mode 100644
index 0000000..0600057
--- /dev/null
+++ b/echoStream/src/phaseOne/Phase1.java
@@ -0,0 +1,130 @@
+package phaseOne;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import components.GlobalHolder;
+import components.Graph;
+import components.Post;
+import components.Tag;
+//import components.popularityHolder;
+import utilities.CreateMedia;
+
+
+
+// Driver Code
+public class Phase1 {
+
+
+// public void display() {
+// System.out.println(this.sharedValues);
+//
+// };
+
+
+
+ public ArrayList getRawTempoData() {
+ ArrayList posts = new ArrayList<>();
+
+ for (int i = 1; i <= 100; i++) {
+ posts.add(new Post("Post " + i, "Caption for post " + i, "HashTag" + i,1,new ArrayList(Arrays.asList("boy", "gay", "sport")) ));
+ }
+
+ return posts;
+ }
+
+ public void printValue() {
+ System.out.println("Shared Value: " + GlobalHolder.getInstance().getAllSharedValues());
+ }
+
+
+ public static void main(String args[]) {
+
+
+
+ Phase1 a = new Phase1();
+
+
+
+
+
+
+// a.setSharedValue("hi",1);
+
+
+
+
+ // Object of graph is created.
+ Graph g = new Graph();
+ CreateMedia createInstance = new CreateMedia();
+// popularityHolder popularList = new popularityHolder();
+
+
+
+
+
+
+ // Edges are added.
+ // Since the graph is bidirectional,
+ // so boolean bidirectional is passed as true.
+
+
+
+
+
+
+// //function( graph, tag, tagPriority, postName, postTitle, tags , postPriority
+// //tag and tagPriority are composite key,(e.g, if girl tag is 1f it always 1f)
+// createInstance.create(g, "girl", "We love Sushi","We love Sushi","girl",2.8f);
+//
+//
+// createInstance.create(g, "boy", "Wtf","We love Sushi","boy",2.8f);
+// createInstance.create(g, "boy", "Sorry","We love Sushi","boy",2.8f);
+// createInstance.create(g,"boy" , "Ha Ha","We love Sushi","boy",1.8f);
+// createInstance.create(g,"girl" , "Ha Ha","We love Sushi","girl",1.8f);
+// createInstance.create(g,"sport" , "HaddHa","We love Sushi","girl",1.8f);
+
+
+
+
+ //jsut like create method , createGroup can be invoked to create with a group of tags
+ createInstance.createGroup(g,new ArrayList(Arrays.asList("boy", "girl", "sport")), "Ha Ha bel","We love Sushi","sport",1.8f);
+ createInstance.createGroup(g,new ArrayList(Arrays.asList("boy", "gay", "sport")), "Sa tar par","We love Sushi","sport",1.8f);
+ createInstance.createGroup(g,new ArrayList(Arrays.asList("Funny", "DC", "Mavel")), "Mike tel","We love Sushi","sport",1.8f);
+
+
+// createInstance.create(g, new String[] {"sport","boy"},1.5f, "Really, Yeah","Really, Yeah","sport",2.5f);
+
+
+
+// g.getKey(new Tag("boy", 3f));
+// g.setPriority(new Tag("boy", 3f), "Sorry", 3f);
+ g.setTagPopularity(new Tag("boy"),0f);
+ g.setPriority(new Tag("girl"), "Ha Ha bel", 0.8f);
+// g.getKey(new Tag("boy", 3f));
+ // Printing the graph
+ System.out.println("Graph:\n" + g.toString());
+
+ // Gives the no of vertices in the graph.
+ g.getVertexCount();
+
+ // Gives the no of edges in the graph.
+ g.getEdgesCount();
+
+
+
+
+// Tells whether the edge is present or not.
+// g.hasEdge("sport", 4);
+//
+// // Tells whether vertex is present or not
+// g.hasVertex("sport");
+//
+// // Prints the neighbors of a vertex
+// g.neighbours("sport");
+ a.printValue();
+ }
+}
+
+
+
+
diff --git a/echoStream/src/utilities/CreateMedia.java b/echoStream/src/utilities/CreateMedia.java
new file mode 100644
index 0000000..af2eb10
--- /dev/null
+++ b/echoStream/src/utilities/CreateMedia.java
@@ -0,0 +1,65 @@
+package utilities;
+
+import components.Tag;
+import components.Post;
+
+import java.util.ArrayList;
+
+import components.GlobalHolder;
+import components.Graph;
+
+
+
+public class CreateMedia {
+
+
+
+ //create method for adding into the map.
+ public void create(Graph g,String tags,String postName,String postCaption,String hashTag,float postPriority,ArrayList tagsGroup) {
+
+
+ Tag tag = new Tag(tags );
+ Post post = new Post(postName, postCaption, hashTag, postPriority, tagsGroup);
+ GlobalHolder.getInstance().setSharedValue(tags,1f);
+ g.addEdge(tag, post);
+
+
+
+
+
+ }
+
+
+
+ //just like create method, support for creating with a number of tags
+ public void createGroup(Graph g,ArrayList tags,String postName,String postCaption,String hashTag,float postPriority) {
+
+ for(int i = 0; i < tags.size(); i++) {
+ create(g,tags.get(i),postName,postCaption,hashTag,postPriority,tags);
+
+ }
+
+
+
+
+
+
+}
+
+
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+
+
+ }
+
+
+
+
+
+
+
+
+}
+
+//Tag name[accepted as array ] and Post-> accepted Post, caption, Hashtag
diff --git a/echoStream/src/utilities/TagComparator.java b/echoStream/src/utilities/TagComparator.java
new file mode 100644
index 0000000..128360e
--- /dev/null
+++ b/echoStream/src/utilities/TagComparator.java
@@ -0,0 +1,21 @@
+package utilities;
+
+import java.util.Comparator;
+import interfaces.HasTag;
+
+public class TagComparator implements Comparator {
+ @Override
+ public int compare(T t1, T t2) {
+ // First compare by popularity
+ int popularityComparison = Float.compare(t1.getPopularity(), t2.getPopularity());
+
+ // If the popularity is the same, compare alphabetically by title
+// if (popularityComparison == 0) {
+// return t1.getTitle().compareTo(t2.getTitle());
+// }
+ if (popularityComparison == 0) {
+ return t1.getTitle().compareTo(t2.getTitle());
+ }
+ return popularityComparison;
+ }
+}