I have a dataset of teachers and students. Each teacher is related to 4 or 5 students but there is no relationship between teachers. I made a nodes and edges file (CSV).
I want to make a network graph in circular format where teachers are along the circumference and students in the center of the circle. And relationship is shown by lines/edges from teachers to students. How to do that in Gephi? I am completely clueless.
Nodes : T1,T2,S1,S2,S3,S4,S5 (T stands for teacher and S for student)
Edges : T1-S1,T1-S3,T1-S4,T2-S1,T2-S5,T2-S4
Related
There are four requirement!
There are schools, students, and clubs.
Every student attends one and only one school; every school has more than one student.
Every student may optionally join one club; every club has more than one student.
Every club belongs to one school; some schools have more than one club,
some schools have none.
Any student may work as an assistants for only one school; every
school may have one assistant at most.
How to draw the 4th requirement in my picture
It's called relation you will insert a middle relation. So for example
(student)0,1 ---> (assistant) <----0,1(School)
So the trick is to create a new entity. And you throw those relation. A student may be or not be an assistant (0,1 means that) and a school may have or not have one assistant.
I have some employees who have conflict in positions, depending on their contract they are working as Labors but in the field they are working as drivers, in my database I am recording every position source as relationship between an employ node and role node. what I am trying to figure out is, how should I query the count of employ with no conflict between both relationship, and if there is conflict I want to count the employees distinctly depending on the role of each relationship, for example:
I have the following:
3 employee have driver contract and working as drivers, so their both relationship connected to the driver node.
4 employee have labor contract and working as drivers, so one relationship connect to the labor node and the other connected to driver node.
10 employee have labor contract and working as labor, so their both relationship connected to the labor node.
Look at the model here
MATCH (m2)<-[r2 {source:"operation"}]-(e:Employee)-[r1 {source:"contract"}]->(m1) RETURN distinct m1.name as contract_position, m2.name as operation_position, count(e)
I tried this and it did almost what I want but if I had more than two relationship (more than two sources), I don't think it will work.
keep in mind that I have more roles than theses two roles and I would like to get a nice understanding between what in paper and what in operation.
PS: I am just starting to learn about graph databases and neo4j, so give some slack :)
In Neo4j, I want to create relationship between nodes where both the nodes are related with a common node.
For Example, I have three nodes where 2 student nodes and a teacher node. I already have relation between student and teacher. Now I want to create a third relationship between student to student where both the students are already related to the same teacher.
In the above image T1 and T2 are teacher nodes. S1, S2, S3 and S4 are student nodes. The relationships which are in blue is already created. now I want to create the relationships which are given in yellow.
Please help. Thanks in Advance.
1) If simple:
// Choose a pair of students with common teacher
MATCH p = (S1:Student)-[:has_teacher]->(T:Teacher)<-[:has_teacher]-(S2:Student)
// Without [:common_teacher] relationships
WHERE NOT (S1)-[:common_teacher]-(S2)
// And create relationships
CREATE (S1)-[r1:common_teacher]->(S2)
CREATE (S2)-[r2:common_teacher]->(S1)
2) If on the other:
You do not need to create additional relationships between the students, because they are already bound by a common teacher.
I am currently writing a program which maps students to courses. Currently, I am using a SAT-Solver, but I am trying to implement a polynomial time / non greedy algorithm which solves the following sub-problem:
There are students (50-150)
There are subjects (10-20), e.g. 'math', 'biology', 'art'
There are courses per subject (at least one), e.g. 'math-1', 'math-2', 'biology-1', 'art-1', 'art-2', 'art-3'
A student selects some (fixed) subjects (10-12) and for each subject the student has to be assigned to exactly one of the existing courses (if possible). It does not matter which course 'math-1' or 'math-2' is being selected.
The courses have a maximum number of allowed students (20-34)
Each course is in a fixed block (= timeslot 1 to 13)
A student may not be assigned to courses being in the same block
I am now describing what I have done so far.
(1) Ignoring the course-student-limit
I was able to solve this with the hungarian algorithm / bipartite matching. Each student may be computed individually by modelling it as following:
left nodes represent the subjects 'math', 'biology', 'art' (of the student)
right nodes represent the blocks '1', '2', .... '13'
an edge is inserted for each course from 'subject' to 'block'
This way the student is assigned for every subject to a course while not attending courses which are in the same block. But course-limits are ignored.
(2) Ignoring the selected subjects of the student
I was able to solve this with a max-flow-algorithm. For each student the following is modelled:
Layer 1: From source to each student with a flow of 13
Layer 2: From each student to his/her personal block with a flow of 1
Layer 3: From each student-block to each course in that block with flow 1
Layer 4: From each course to the sink with 'max-student-limit'
This way the student selects arbitrary courses and the course-limit is fullfilled. But he/she may be unlucky and be assigned to 'math-1', 'math-2' and 'math-3' ignoring the subjects 'biology' and 'art'.
(3) Greedy Hungarian
Another idea I had was to match one student at a time with the hungarian algorithm and adjusting the weights so that 'more empty courses' are preferred. For example one could model:
left nodes are subjects of the student
right nodes are blocks
for each course insert an edge from subject to the block of the course with weight = number of free seats
And then computing a Maximum-Weight-Matching.
I would really appreciate any suggestions / help.
Thank you!
Below is an illustration of the kind of data I want to save in Core data. Every city has many schools , every school has many grades and every grade has many students and their details.
I have read a couple of things about Core data and have got it up and starting. But I'm not able to understand how to save an array in core data and is it a good way to do that in the similar case of the illustration?
If i want to save for a particular school an array of total students for that particular grade, would it be a good practice? If yes, is the method provided in this link good to follow?
EDIT : All cities, all schools and all students have same attributes. Whereas each grade has different attributes. So if there are data for 10 grades, there may be 10 types of array for grades.
Also, what if i have a one to many relation between school and students? IE depending on my login i decide whether i need to save school and grades or school and students. How would the relationship be now?
You should use core data with one to many relationship. This would be your entity structure.
UPDATE:
In case you have several grades with different attributes, you can define another entity "GradeType", which contains details of each grades
UPDATE 2:
Let me write down considerations in this scenario.
1. A city can have multiple schools in it, but a school can be only in one city (Branches will have different address ;) ).
2. A school may offer multiple subjects. same subject can be taught in multiple cities.
3. A school may contain multiple students while a student can be enrolled only in one school.
4. A student can register for multiple subjects, while same subject can be registered by multiple students.
5. There can be multiple grades possible for a subject.(lets say 4: A, B, C & D). Similarly, many subjects will follow the same grading system.(A in history, B in Geology etc).
6. A student can have multiple grades. However, the number of grades will be equal to number of subject he/she opted for.
Based on above consideration, this would be your dataModel.
Here Grades Entity will have entries like this:
grade A for physics is scored by these students.
grade A for biology is scored by these students.
…
…
grade B for physics is scored by these students.
grade B for biology is scored by these students.
…
… N So on
Let me know if more info needed.
Dont do it the way shown in that link. Create core data entities for each of them (city,school,grade,student). Add relationship between those entities (Eg: City ->> school which means one to many relationships). Check this link http://www.raywenderlich.com/14742/core-data-on-ios-5-tutorial-how-to-work-with-relations-and-predicates. Refer apple document https://developer.apple.com/library/mac/documentation/cocoa/conceptual/coredata/articles/cdRelationships.html as well. Take your time with core data modelling. Hope it helps