public bool AddToWeight(Note note, double to_add) { if (IsConnected(note)) { connections[NoteUtil.NoteHash(note)].weight += to_add; return(true); } return(false); }
// Returns true if adding the node was successful // Returns false if the Note in the NoteNode being added is already connected public bool AddConnection(NoteNode note, double weight) { if (!IsConnected(note.GetNote())) { connections[NoteUtil.NoteHash(note.GetNote())] = new Edge(note, weight); return(true); } return(false); }
// Returns boolean representing success of the operation public bool SetWeight(Note note, double new_weight) { if (IsConnected(note)) { connections[NoteUtil.NoteHash(note)].weight = new_weight; return(true); } return(false); }
private void ModifyConnectionWeight(Note from, Note to, double by) { double distribute_to_rest = -((1.00 / (NoteUtil.NOTE_COUNT - 1)) * by); nodes[NoteUtil.NoteHash(from)].AddToWeight(to, by); for (int i = 0; i < NoteUtil.NOTE_COUNT; ++i) { if (i == NoteUtil.NoteHash(to)) { continue; } nodes[NoteUtil.NoteHash(from)].AddToWeight(nodes[i].GetNote(), distribute_to_rest); } }
public NoteGraph() { double initial_weight = 1.00 / 22.00; for (int i = 0; i < NoteUtil.NOTE_COUNT; ++i) { nodes[i] = new NoteNode(NoteUtil.GetNoteAtIndex(i)); } for (int i = 0; i < NoteUtil.NOTE_COUNT; ++i) { for (int k = 0; k < NoteUtil.NOTE_COUNT; ++k) { nodes[i].AddConnection(nodes[k], initial_weight); } } }
private bool IsConnected(Note note) { return(connections[NoteUtil.NoteHash(note)] != null); }
public double GetEdgeWeight(Note note) { return(connections[NoteUtil.NoteHash(note)].weight); }